Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gram-data/d3-gram

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gram-data/d3-gram - npm Package Compare versions

Comparing version 0.1.19 to 0.1.20

17

dist/d3-gram.cjs.development.js

@@ -5,4 +5,9 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var gramOps = require('@gram-data/gram-ops');
var gramAst = require('@gram-data/gram-ast');
var unified = _interopDefault(require('unified'));
var gramParse = require('@gram-data/gram-parse');
var gramPresetBasic = require('@gram-data/gram-preset-basic');

@@ -30,9 +35,3 @@ var MISSING_ID = '__missing_id__';

var unified = /*#__PURE__*/require('unified');
var gramParserPlugin = /*#__PURE__*/require('@gram-data/gram-parse').gramParserPlugin;
var gramPresetBasic = /*#__PURE__*/require('@gram-data/gram-preset-basic');
var gramProcessor = /*#__PURE__*/unified().use(gramParserPlugin).use(gramPresetBasic);
var gramProcessor = /*#__PURE__*/unified().use(gramParse.gramParserPlugin).use(gramPresetBasic);
/**

@@ -49,5 +48,3 @@ * Parses text as [gram](https://github.com/gram-data/gram-js),

nodes: gramOps.nodes(parsed).map(nodeToD3),
links: parsed.children.reduce(function (acc, p) {
return acc.concat(gramOps.edges(p).map(edgeToD3));
}, []),
links: gramOps.edges(parsed).map(edgeToD3),
paths: []

@@ -54,0 +51,0 @@ };

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@gram-data/gram-ops"),e=require("@gram-data/gram-ast"),n="__missing_id__",t=function(r,e,t){return{id:r||n,labels:e||[],record:t||{}}},a=function(r,e,t,a,i){return{id:t||n,labels:a||[],record:i||{},source:r,target:e}},i=require("unified"),d=require("@gram-data/gram-parse").gramParserPlugin,o=require("@gram-data/gram-preset-basic"),u=i().use(d).use(o),s=function(e){var n=u.runSync(u.parse(e));return{nodes:r.nodes(n).map(c),links:n.children.reduce((function(e,n){return e.concat(r.edges(n).map(m))}),[]),paths:[]}},c=function(r){return e.isGramNode(r)?t(r.id,r.labels,r.record):t("random")},m=function(r){return a(function(r){return"left"===r.kind?r.children[1].id||n:r.children[0].id||n}(r),function(r){return"left"===r.kind?r.children[0].id||n:r.children[1].id||n}(r),r.id,r.labels,r.record)};exports.MISSING_ID=n,exports.d3Gram=s,exports.default=s,exports.edgeToD3=m,exports.isGramNodeDatum=function(r){return void 0!==r.id},exports.makeGramLinkDatum=a,exports.makeGramNodeDatum=t,exports.nodeToD3=c;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("@gram-data/gram-ops"),t=require("@gram-data/gram-ast"),a=(e=require("unified"))&&"object"==typeof e&&"default"in e?e.default:e,i=require("@gram-data/gram-parse"),n=require("@gram-data/gram-preset-basic"),d="__missing_id__",o=function(e,r,t){return{id:e||d,labels:r||[],record:t||{}}},u=function(e,r,t,a,i){return{id:t||d,labels:a||[],record:i||{},source:e,target:r}},s=a().use(i.gramParserPlugin).use(n),m=function(e){var t=s.runSync(s.parse(e));return{nodes:r.nodes(t).map(c),links:r.edges(t).map(l),paths:[]}},c=function(e){return t.isGramNode(e)?o(e.id,e.labels,e.record):o("random")},l=function(e){return u(function(e){return"left"===e.kind?e.children[1].id||d:e.children[0].id||d}(e),function(e){return"left"===e.kind?e.children[0].id||d:e.children[1].id||d}(e),e.id,e.labels,e.record)};exports.MISSING_ID=d,exports.d3Gram=m,exports.default=m,exports.edgeToD3=l,exports.isGramNodeDatum=function(e){return void 0!==e.id},exports.makeGramLinkDatum=u,exports.makeGramNodeDatum=o,exports.nodeToD3=c;
//# sourceMappingURL=d3-gram.cjs.production.min.js.map
import { nodes, edges } from '@gram-data/gram-ops';
import { isGramNode } from '@gram-data/gram-ast';
import unified from 'unified';
import { gramParserPlugin } from '@gram-data/gram-parse';
import * as gramPresetBasic from '@gram-data/gram-preset-basic';

@@ -25,8 +28,2 @@ var MISSING_ID = '__missing_id__';

var unified = /*#__PURE__*/require('unified');
var gramParserPlugin = /*#__PURE__*/require('@gram-data/gram-parse').gramParserPlugin;
var gramPresetBasic = /*#__PURE__*/require('@gram-data/gram-preset-basic');
var gramProcessor = /*#__PURE__*/unified().use(gramParserPlugin).use(gramPresetBasic);

@@ -44,5 +41,3 @@ /**

nodes: nodes(parsed).map(nodeToD3),
links: parsed.children.reduce(function (acc, p) {
return acc.concat(edges(p).map(edgeToD3));
}, []),
links: edges(parsed).map(edgeToD3),
paths: []

@@ -49,0 +44,0 @@ };

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(((e=e||self).gram=e.gram||{},e.gram.d3={}))}(this,(function(e){"use strict";var r=function(e){return function(e){return!!e.type&&"path"===e.type}(e)&&e.children&&0===e.children.length&&"ø"!==e.id};function n(){return(n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var i=function e(r){return void 0===r.children||0===r.children.length?r:e(r.children[0])},t=function e(r){return void 0===r.children||0===r.children.length?r:e(r.children[r.children.length-1])},d=function e(n){if(r(n))return[n];if((i=n).type&&"seq"===i.type)return e(n.children);var i;if(Array.isArray(n)){var t=[],d=n.map(e).flat().reduce((function(e,r){return r.id?e.has(r.id)?e.set(r.id,Object.assign(e.get(r.id),r)):e.set(r.id,r):t.push(r),e}),new Map);return Array.from(d.values()).concat(t)}return e(n.children)},c="__missing_id__",a=function(e,r,n){return{id:e||c,labels:r||[],record:n||{}}},u=function(e,r,n,i,t){return{id:n||c,labels:i||[],record:t||{},source:e,target:r}},o=require("unified"),l=require("@gram-data/gram-parse").gramParserPlugin,f=require("@gram-data/gram-preset-basic"),s=o().use(l).use(f),h=function(e){var r=s.runSync(s.parse(e));return{nodes:d(r).map(p),links:r.children.reduce((function(e,r){return e.concat(function e(r){return void 0===r||void 0===r.children||0===r.children.length?[]:2===r.children.length?[].concat(e(r.children[0]),void 0!==r.kind&&"pair"!==r.kind?[(d=[t(r.children[0]),i(r.children[1])],c=r.kind,a=r.id,u=r.labels,o=r.record,n({type:"path",id:a},u&&{labels:u},o&&{record:o},{kind:c,children:d}))]:[],e(r.children[1])):r.children.reduce((function(r,n){return[].concat(r,e(n))}),[]);var d,c,a,u,o}(r).map(m))}),[]),paths:[]}},p=function(e){return r(e)?a(e.id,e.labels,e.record):a("random")},m=function(e){return u(function(e){return"left"===e.kind?e.children[1].id||c:e.children[0].id||c}(e),function(e){return"left"===e.kind?e.children[0].id||c:e.children[1].id||c}(e),e.id,e.labels,e.record)};e.MISSING_ID=c,e.d3Gram=h,e.default=h,e.edgeToD3=m,e.isGramNodeDatum=function(e){return void 0!==e.id},e.makeGramLinkDatum=u,e.makeGramNodeDatum=a,e.nodeToD3=p,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).gram=e.gram||{},e.gram.d3={}))}(this,(function(e){"use strict";var t=/[0-9a-zA-Z_@]+\b@*/,n=new RegExp("^"+t.source+"$"),r={__proto__:null,boolean:/true|false|TRUE|FALSE\b(?!@)/,hexadecimal:/-?0x(?:[0-9a-fA-F]+)\b(?!@)/,octal:/-?0(?:[0-7]+)\b(?!@)/,measurement:/-?(?:[0-9]|[1-9][0-9]+)(?:\.[0-9]+)?[a-zA-Z]+\b(?!@)/,decimal:/-?(?:[0-9]|[1-9][0-9]+)\.[0-9]+(?:[eE][-+]?[0-9]+)?\b(?!@)/,integer:/-?(?:[0-9]|[1-9][0-9]+)(?:[eE][-+]?[0-9]+)?\b(?!@)/,taggedString:/[a-zA-Z][0-9a-zA-Z_@]*`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,doubleQuotedString:/"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*"/,singleQuotedString:/'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*'/,tickedString:/`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,symbol:/[a-zA-Z_][0-9a-zA-Z_]*\b(?!@)/,identifier:t,isValidIdentifier:function(e){return e&&n.test(e)}},o=function(e){return!!e.type&&"path"===e.type},i=function(e){return o(e)&&"ø"===e.id},s=function(e){return o(e)&&e.children&&0===e.children.length&&"ø"!==e.id};function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e){return Array.isArray(e)?e:e instanceof Function?l(e()):void 0===e?[]:[e]}var u=function(e,t,n,r){return a({type:"seq",id:t},n&&{labels:n},r&&{record:r},{children:l(e)})},c=function(e,t){return void 0===e&&(e="pair"),t.length>1?t.slice(0,t.length-1).reduceRight((function(t,n){return f([n,t],{kind:e})}),t[t.length-1]):t[0]},f=function(e,t){void 0===t&&(t={});var n=a({type:"path"},t.id&&{id:t.id},t.labels&&{labels:t.labels},t.record&&{record:t.record});if(void 0===e)return n.id&&"ø"!==n.id?(n.children=[],n):(n.children=void 0,p);if(0===e.length)return"ø"===n.id?p:(n.children=[],n);if(1===e.length){var r=e[0];return i(r)?(n.children=[],n):(n.children=[r],n)}if(2===e.length){if(t.kind&&"pair"!==t.kind&&s(e[0])&&s(e[1]))return n.kind=t.kind,n.children=[e[0],e[1]],n;if(i(e[0])&&i(e[1]))return n.kind=t.kind,n.children=[],n;n.children=[e[0],e[1]]}return n.kind=t.kind||"pair",n},p={type:"path",id:"ø",labels:void 0,record:void 0,children:[]},h=function(){return p},d=function(e,t,n){return a({type:"path"},e&&{id:e},t&&{labels:t},n&&{record:n},{children:[]})},m=function(e,t,n,r,o){return a({type:"path",id:n},r&&{labels:r},o&&{record:o},{kind:t,children:e})},y=function(e,t,n,r,o){return a({type:"path",kind:e,id:n},r&&{labels:r},o&&{record:o},{children:t})},b=function(e,t,n,r){return y("pair",e,t,n,r)},g=function(e){return e.reduce((function(e,t){return e[t.name]=t.value,e}),{})},v=function(e){return Object.entries(e).reduce((function(e,t){return e.push(w(t[0],t[1])),e}),[])},w=function(e,t){return{type:"property",name:e,value:t}},x=function(e){return{type:"boolean",value:e?"true":"false"}},S=function(e){return{type:"string",value:e}},k=function(e,t){return{type:"tagged",value:t,tag:e}},$=function(e){return{type:"integer",value:String(e)}},E=function(e){return{type:"decimal",value:String(e)}},P=function(e){return{type:"hexadecimal",value:"number"==typeof e?e.toString(16):e}},_=function(e){return{type:"octal",value:"number"==typeof e?e.toString(8):e}},O=function(e,t){return{type:"measurement",value:String(t),unit:e}},j=function(e){return k("date",e instanceof Date?e.toISOString().slice(0,10):e)},A=function(e){return k("time",e instanceof Date?e.toTimeString():e)},T=function(e){return k("duration",e instanceof Date?"P"+(e.getUTCFullYear()-1970)+"Y"+e.getUTCMonth()+"M"+e.getUTCDate()+"DT"+e.getUTCHours()+"H"+e.getUTCMinutes()+"M"+e.getUTCMilliseconds()/1e3+"S":e)},C=function(e,t){return void 0===t&&(t=1),e.flat(t).filter((function(e){return null!==e}))},N={__proto__:null,seq:u,listToPath:c,cons:f,empty:h,node:d,edge:m,path:y,pair:b,recordToMap:g,mapToRecord:v,pluck:function(e,t){return e.reduce((function(e,n){return n.name===t?n:e}))},property:w,boolean:x,string:S,tagged:k,integer:$,decimal:E,hexadecimal:P,octal:_,measurement:O,year:function(e){return k("date",e instanceof Date?e.getFullYear().toString():e)},date:j,dayOfMonth:function(e){return k("date",e instanceof Date?"--"+e.toISOString().slice(5,10):e)},time:A,duration:T,flatten:C,default:{seq:u,empty:h,cons:f,pair:b,listToPath:c,node:d,edge:m,property:w,boolean:x,string:S,tagged:k,integer:$,decimal:E,hexadecimal:P,octal:_,measurement:O,date:j,time:A,duration:T,flatten:C,recordToMap:g,mapToRecord:v}},L=function e(t){return void 0===t.children||0===t.children.length?t:e(t.children[0])},I=function e(t){return void 0===t.children||0===t.children.length?t:e(t.children[t.children.length-1])},R=function e(t){if(s(t))return[t];if((n=t).type&&"seq"===n.type)return e(t.children);var n;if(Array.isArray(t)){var r=[],o=t.map(e).flat().reduce((function(e,t){return t.id?e.has(t.id)?e.set(t.id,Object.assign(e.get(t.id),t)):e.set(t.id,t):r.push(t),e}),new Map);return Array.from(o.values()).concat(r)}return e(t.children)},q=function e(t){return void 0===t||void 0===t.children||0===t.children.length?[]:2===t.children.length?[].concat(e(t.children[0]),void 0!==t.kind&&"pair"!==t.kind?[m([I(t.children[0]),L(t.children[1])],t.kind,t.id,t.labels,t.record)]:[],e(t.children[1])):t.children.reduce((function(t,n){return[].concat(t,e(n))}),[])},G="__missing_id__",M=function(e,t,n){return{id:e||G,labels:t||[],record:n||{}}},B=function(e,t,n,r,o){return{id:n||G,labels:r||[],record:o||{},source:e,target:t}},V=function(e){if(e)throw e},U=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},D=Object.prototype.hasOwnProperty,F=Object.prototype.toString,z=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,H=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===F.call(e)},K=function(e){if(!e||"[object Object]"!==F.call(e))return!1;var t,n=D.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&D.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!r)return!1;for(t in e);return void 0===t||D.call(e,t)},J=function(e,t){z&&"__proto__"===t.name?z(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},Z=function(e,t){if("__proto__"===t){if(!D.call(e,t))return;if(Q)return Q(e,t).value}return e[t]},X=function e(){var t,n,r,o,i,s,a=arguments[0],l=1,u=arguments.length,c=!1;for("boolean"==typeof a&&(c=a,a=arguments[1]||{},l=2),(null==a||"object"!=typeof a&&"function"!=typeof a)&&(a={});l<u;++l)if(null!=(t=arguments[l]))for(n in t)r=Z(a,n),a!==(o=Z(t,n))&&(c&&o&&(K(o)||(i=H(o)))?(i?(i=!1,s=r&&H(r)?r:[]):s=r&&K(r)?r:{},J(a,{name:n,newValue:e(c,s,o)})):void 0!==o&&J(a,{name:n,newValue:o}));return a},Y=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},W=[].slice,ee=function(e,t){var n;return function(){var t,i=W.call(arguments,0),s=e.length>i.length;s&&i.push(r);try{t=e.apply(null,i)}catch(e){if(s&&n)throw e;return r(e)}s||(t&&"function"==typeof t.then?t.then(o,r):t instanceof Error?r(t):o(t))};function r(){n||(n=!0,t.apply(null,arguments))}function o(e){r(null,e)}},te=re;re.wrap=ee;var ne=[].slice;function re(){var e=[],t={run:function(){var t=-1,n=ne.call(arguments,0,-1),r=arguments[arguments.length-1];if("function"!=typeof r)throw new Error("Expected function as last argument, not "+r);function o(i){var s=e[++t],a=ne.call(arguments,0),l=a.slice(1),u=n.length,c=-1;if(i)r(i);else{for(;++c<u;)null==l[c]&&(l[c]=n[c]);n=l,s?ee(s,o).apply(null,n):r.apply(null,[null].concat(n))}}o.apply(null,[null].concat(n))},use:function(n){if("function"!=typeof n)throw new Error("Expected `fn` to be a function, not "+n);return e.push(n),t}};return t}var oe={}.hasOwnProperty,ie=function(e){return e&&"object"==typeof e?oe.call(e,"position")||oe.call(e,"type")?ae(e.position):oe.call(e,"start")||oe.call(e,"end")?ae(e):oe.call(e,"line")||oe.call(e,"column")?se(e):"":""};function se(e){return e&&"object"==typeof e||(e={}),le(e.line)+":"+le(e.column)}function ae(e){return e&&"object"==typeof e||(e={}),se(e.start)+"-"+se(e.end)}function le(e){return e&&"number"==typeof e?e:1}var ue=pe;function ce(){}ce.prototype=Error.prototype;var fe=pe.prototype=new ce;function pe(e,t,n){var r,o,i;"string"==typeof t&&(n=t,t=null),r=function(e){var t,n=[null,null];return"string"==typeof e&&(-1===(t=e.indexOf(":"))?n[1]=e:(n[0]=e.slice(0,t),n[1]=e.slice(t+1))),n}(n),o=ie(t)||"1:1",i={start:{line:null,column:null},end:{line:null,column:null}},t&&t.position&&(t=t.position),t&&(t.start?(i=t,t=t.start):i.start=t),e.stack&&(this.stack=e.stack,e=e.message),this.message=e,this.name=o,this.reason=e,this.line=t?t.line:null,this.column=t?t.column:null,this.location=i,this.source=r[0],this.ruleId=r[1]}fe.file="",fe.name="",fe.reason="",fe.message="",fe.stack="",fe.fatal=null,fe.column=null,fe.line=null;var he="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function de(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}"function"==typeof he.setTimeout&&setTimeout,"function"==typeof he.clearTimeout&&clearTimeout,new Date;var me=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,ye=function(e){return me.exec(e).slice(1)};function be(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var r=n>=0?arguments[n]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(e=r+"/"+e,t="/"===r.charAt(0))}return(t?"/":"")+(e=de(Pe(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function ge(e){var t=ve(e),n="/"===_e(e,-1);return(e=de(Pe(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e}function ve(e){return"/"===e.charAt(0)}function we(){var e=Array.prototype.slice.call(arguments,0);return ge(Pe(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function xe(e,t){function n(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=be(e).substr(1),t=be(t).substr(1);for(var r=n(e.split("/")),o=n(t.split("/")),i=Math.min(r.length,o.length),s=i,a=0;a<i;a++)if(r[a]!==o[a]){s=a;break}var l=[];for(a=s;a<r.length;a++)l.push("..");return(l=l.concat(o.slice(s))).join("/")}function Se(e){var t=ye(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function ke(e,t){var n=ye(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n}function $e(e){return ye(e)[3]}var Ee={extname:$e,basename:ke,dirname:Se,sep:"/",delimiter:":",relative:xe,join:we,isAbsolute:ve,normalize:ge,resolve:be};function Pe(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var _e="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)},Oe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function je(e,t){return e(t={exports:{}},t.exports),t.exports}var Ae,Te=(Ae={__proto__:null,resolve:be,normalize:ge,isAbsolute:ve,join:we,relative:xe,sep:"/",delimiter:":",dirname:Se,basename:ke,extname:$e,default:Ee})&&Ae.default||Ae,Ce=Re,Ne={}.hasOwnProperty,Le=Re.prototype,Ie=["history","path","basename","stem","extname","dirname"];function Re(e){var t,n,r;if(e){if("string"==typeof e||U(e))e={contents:e};else if("message"in e&&"messages"in e)return e}else e={};if(!(this instanceof Re))return new Re(e);for(this.data={},this.messages=[],this.history=[],this.cwd="/",n=-1,r=Ie.length;++n<r;)Ne.call(e,t=Ie[n])&&(this[t]=e[t]);for(t in e)-1===Ie.indexOf(t)&&(this[t]=e[t])}function qe(e,t){if(-1!==e.indexOf(Te.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Te.sep+"`")}function Ge(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Me(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}Le.toString=function(e){var t=this.contents||"";return U(t)?t.toString(e):String(t)},Object.defineProperty(Le,"path",{get:function(){return this.history[this.history.length-1]},set:function(e){Ge(e,"path"),e!==this.path&&this.history.push(e)}}),Object.defineProperty(Le,"dirname",{get:function(){return"string"==typeof this.path?Te.dirname(this.path):void 0},set:function(e){Me(this.path,"dirname"),this.path=Te.join(e||"",this.basename)}}),Object.defineProperty(Le,"basename",{get:function(){return"string"==typeof this.path?Te.basename(this.path):void 0},set:function(e){Ge(e,"basename"),qe(e,"basename"),this.path=Te.join(this.dirname||"",e)}}),Object.defineProperty(Le,"extname",{get:function(){return"string"==typeof this.path?Te.extname(this.path):void 0},set:function(e){var t=e||"";if(qe(t,"extname"),Me(this.path,"extname"),t){if("."!==t.charAt(0))throw new Error("`extname` must start with `.`");if(-1!==t.indexOf(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=function(e,t){if("string"!=typeof e)return e;if(0===e.length)return e;var n=Te.basename(e,Te.extname(e))+t;return Te.join(Te.dirname(e),n)}(this.path,t)}}),Object.defineProperty(Le,"stem",{get:function(){return"string"==typeof this.path?Te.basename(this.path,this.extname):void 0},set:function(e){Ge(e,"stem"),qe(e,"stem"),this.path=Te.join(this.dirname||"",e+(this.extname||""))}});var Be=Ce,Ve=Ce.prototype;Ve.message=function(e,t,n){var r=this.path,o=new ue(e,t,n);return r&&(o.name=r+":"+o.name,o.file=r),o.fatal=!1,this.messages.push(o),o},Ve.info=function(){var e=this.message.apply(this,arguments);return e.fatal=null,e},Ve.fail=function(){var e=this.message.apply(this,arguments);throw e.fatal=!0,e};var Ue=function e(){var t=[],n=te(),r={},o=!1,i=-1;return s.data=function(e,t){return"string"==typeof e?2===arguments.length?(Je("data",o),r[e]=t,s):Fe.call(r,e)&&r[e]||null:e?(Je("data",o),r=e,s):r},s.freeze=a,s.attachers=t,s.use=function(e){var n;if(Je("use",o),null==e);else if("function"==typeof e)c.apply(null,arguments);else{if("object"!=typeof e)throw new Error("Expected usable value, not `"+e+"`");"length"in e?u(e):i(e)}return n&&(r.settings=X(r.settings||{},n)),s;function i(e){u(e.plugins),e.settings&&(n=X(n||{},e.settings))}function a(e){if("function"==typeof e)c(e);else{if("object"!=typeof e)throw new Error("Expected usable value, not `"+e+"`");"length"in e?c.apply(null,e):i(e)}}function u(e){var t,n;if(null==e);else{if("object"!=typeof e||!("length"in e))throw new Error("Expected a list of plugins, not `"+e+"`");for(t=e.length,n=-1;++n<t;)a(e[n])}}function c(e,n){var r=l(e);r?(Y(r[1])&&Y(n)&&(n=X(r[1],n)),r[1]=n):t.push(De.call(arguments))}},s.parse=function(e){var t,n=Be(e);return a(),He("parse",t=s.Parser),Qe(t,"parse")?new t(String(n),n).parse():t(String(n),n)},s.stringify=function(e,t){var n,r=Be(t);return a(),Ke("stringify",n=s.Compiler),Ze(e),Qe(n,"compile")?new n(e,r).compile():n(e,r)},s.run=u,s.runSync=function(e,t){var n,r=!1;return u(e,t,(function(e,t){r=!0,V(e),n=t})),Xe("runSync","run",r),n},s.process=c,s.processSync=function(e){var t,n=!1;return a(),He("processSync",s.Parser),Ke("processSync",s.Compiler),c(t=Be(e),(function(e){n=!0,V(e)})),Xe("processSync","process",n),t},s;function s(){for(var n=e(),o=t.length,i=-1;++i<o;)n.use.apply(null,t[i]);return n.data(X(!0,{},r)),n}function a(){var e,r,a,l;if(o)return s;for(;++i<t.length;)r=(e=t[i])[0],!1!==(a=e[1])&&(!0===a&&(e[1]=void 0),"function"==typeof(l=r.apply(s,e.slice(1)))&&n.use(l));return o=!0,i=Infinity,s}function l(e){for(var n,r=t.length,o=-1;++o<r;)if((n=t[o])[0]===e)return n}function u(e,t,r){if(Ze(e),a(),r||"function"!=typeof t||(r=t,t=null),!r)return new Promise(o);function o(o,i){n.run(e,Be(t),(function(t,n,s){n=n||e,t?i(t):o?o(n):r(null,n,s)}))}o(null,r)}function c(e,t){if(a(),He("process",s.Parser),Ke("process",s.Compiler),!t)return new Promise(n);function n(n,r){var o=Be(e);ze.run(s,{file:o},(function(e){e?r(e):n?n(o):t(null,o)}))}n(null,t)}}().freeze(),De=[].slice,Fe={}.hasOwnProperty,ze=te().use((function(e,t){t.tree=e.parse(t.file)})).use((function(e,t,n){e.run(t.tree,t.file,(function(e,r,o){e?n(e):(t.tree=r,t.file=o,n())}))})).use((function(e,t){var n=e.stringify(t.tree,t.file),r=t.file;null==n||("string"==typeof n||U(n)?r.contents=n:r.result=n)}));function Qe(e,t){return"function"==typeof e&&e.prototype&&(function(e){var t;for(t in e)return!0;return!1}(e.prototype)||t in e.prototype)}function He(e,t){if("function"!=typeof t)throw new Error("Cannot `"+e+"` without `Parser`")}function Ke(e,t){if("function"!=typeof t)throw new Error("Cannot `"+e+"` without `Compiler`")}function Je(e,t){if(t)throw new Error("Cannot invoke `"+e+"` on a frozen processor.\nCreate a new processor first, by invoking it: use `processor()` instead of `processor`.")}function Ze(e){if(!e||"string"!=typeof e.type)throw new Error("Expected node, got `"+e+"`")}function Xe(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}var Ye=je((function(e){var t,n;t=Oe,n=function(){function e(t,n,r){return this.id=++e.highestId,this.name=t,this.symbols=n,this.postprocess=r,this}function t(e,t,n,r){this.rule=e,this.dot=t,this.reference=n,this.data=[],this.wantedBy=r,this.isComplete=this.dot===e.symbols.length}function n(e,t){this.grammar=e,this.index=t,this.states=[],this.wants={},this.scannable=[],this.completed={}}function r(e,t){this.rules=e,this.start=t||this.rules[0].name;var n=this.byName={};this.rules.forEach((function(e){n.hasOwnProperty(e.name)||(n[e.name]=[]),n[e.name].push(e)}))}function o(){this.reset("")}function i(e,t,i){if(e instanceof r){var s=e;i=t}else s=r.fromCompiled(e,t);for(var a in this.grammar=s,this.options={keepHistory:!1,lexer:s.lexer||new o},i||{})this.options[a]=i[a];this.lexer=this.options.lexer,this.lexerState=void 0;var l=new n(s,0);this.table=[l],l.wants[s.start]=[],l.predict(s.start),l.process(),this.current=0}function s(e){var t=typeof e;if("string"===t)return e;if("object"===t){if(e.literal)return JSON.stringify(e.literal);if(e instanceof RegExp)return e.toString();if(e.type)return"%"+e.type;if(e.test)return"<"+String(e.test)+">";throw new Error("Unknown symbol type: "+e)}}return e.highestId=0,e.prototype.toString=function(e){var t=void 0===e?this.symbols.map(s).join(" "):this.symbols.slice(0,e).map(s).join(" ")+" ● "+this.symbols.slice(e).map(s).join(" ");return this.name+" → "+t},t.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},t.prototype.nextState=function(e){var n=new t(this.rule,this.dot+1,this.reference,this.wantedBy);return n.left=this,n.right=e,n.isComplete&&(n.data=n.build(),n.right=void 0),n},t.prototype.build=function(){var e=[],t=this;do{e.push(t.right.data),t=t.left}while(t.left);return e.reverse(),e},t.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,i.fail))},n.prototype.process=function(e){for(var t=this.states,n=this.wants,r=this.completed,o=0;o<t.length;o++){var s=t[o];if(s.isComplete){if(s.finish(),s.data!==i.fail){for(var a=s.wantedBy,l=a.length;l--;)this.complete(a[l],s);s.reference===this.index&&(this.completed[u=s.rule.name]=this.completed[u]||[]).push(s)}}else{var u;if("string"!=typeof(u=s.rule.symbols[s.dot])){this.scannable.push(s);continue}if(n[u]){if(n[u].push(s),r.hasOwnProperty(u)){var c=r[u];for(l=0;l<c.length;l++)this.complete(s,c[l])}}else n[u]=[s],this.predict(u)}}},n.prototype.predict=function(e){for(var n=this.grammar.byName[e]||[],r=0;r<n.length;r++){var o=new t(n[r],0,this.index,this.wants[e]);this.states.push(o)}},n.prototype.complete=function(e,t){var n=e.nextState(t);this.states.push(n)},r.fromCompiled=function(t,n){var o=t.Lexer;t.ParserStart&&(n=t.ParserStart,t=t.ParserRules);var i=new r(t=t.map((function(t){return new e(t.name,t.symbols,t.postprocess)})),n);return i.lexer=o,i},o.prototype.reset=function(e,t){this.buffer=e,this.index=0,this.line=t?t.line:1,this.lastLineBreak=t?-t.col:0},o.prototype.next=function(){if(this.index<this.buffer.length){var e=this.buffer[this.index++];return"\n"===e&&(this.line+=1,this.lastLineBreak=this.index),{value:e}}},o.prototype.save=function(){return{line:this.line,col:this.index-this.lastLineBreak}},o.prototype.formatError=function(e,t){var n=this.buffer;if("string"==typeof n){var r=n.split("\n").slice(Math.max(0,this.line-5),this.line),o=n.indexOf("\n",this.index);-1===o&&(o=n.length);var i=this.index-this.lastLineBreak,s=String(this.line).length;return t+=" at line "+this.line+" col "+i+":\n\n",(t+=r.map((function(e,t){return a(this.line-r.length+t+1,s)+" "+e}),this).join("\n"))+"\n"+a("",s+i)+"^\n"}return t+" at index "+(this.index-1);function a(e,t){var n=String(e);return Array(t-n.length+1).join(" ")+n}},i.fail={},i.prototype.feed=function(e){var t,r=this.lexer;for(r.reset(e,this.lexerState);;){try{if(!(t=r.next()))break}catch(e){var i=new n(this.grammar,this.current+1);throw this.table.push(i),(l=new Error(this.reportLexerError(e))).offset=this.current,l.token=e.token,l}var s=this.table[this.current];this.options.keepHistory||delete this.table[this.current-1];var a=this.current+1;i=new n(this.grammar,a),this.table.push(i);for(var l,u=void 0!==t.text?t.text:t.value,c=r.constructor===o?t.value:t,f=s.scannable,p=f.length;p--;){var h=f[p],d=h.rule.symbols[h.dot];if(d.test?d.test(c):d.type?d.type===t.type:d.literal===u){var m=h.nextState({data:c,token:t,isToken:!0,reference:a-1});i.states.push(m)}}if(i.process(),0===i.states.length)throw(l=new Error(this.reportError(t))).offset=this.current,l.token=t,l;this.options.keepHistory&&(s.lexerState=r.save()),this.current++}return s&&(this.lexerState=r.save()),this.results=this.finish(),this},i.prototype.reportLexerError=function(e){var t,n,r=e.token;return r?(t="input "+JSON.stringify(r.text[0])+" (lexer error)",n=this.lexer.formatError(r,"Syntax error")):(t="input (lexer error)",n=e.message),this.reportErrorCommon(n,t)},i.prototype.reportError=function(e){var t=(e.type?e.type+" token: ":"")+JSON.stringify(void 0!==e.value?e.value:e),n=this.lexer.formatError(e,"Syntax error");return this.reportErrorCommon(n,t)},i.prototype.reportErrorCommon=function(e,t){var n=[];n.push(e);var r=this.table[this.table.length-2],o=r.states.filter((function(e){var t=e.rule.symbols[e.dot];return t&&"string"!=typeof t}));return 0===o.length?(n.push("Unexpected "+t+". I did not expect any more input. Here is the state of my parse table:\n"),this.displayStateStack(r.states,n)):(n.push("Unexpected "+t+". Instead, I was expecting to see one of the following:\n"),o.map((function(e){return this.buildFirstStateStack(e,[])||[e]}),this).forEach((function(e){var t=e[0],r=this.getSymbolDisplay(t.rule.symbols[t.dot]);n.push("A "+r+" based on:"),this.displayStateStack(e,n)}),this)),n.push(""),n.join("\n")},i.prototype.displayStateStack=function(e,t){for(var n,r=0,o=0;o<e.length;o++){var i=e[o],s=i.rule.toString(i.dot);s===n?r++:(r>0&&t.push(" ^ "+r+" more lines identical to this"),r=0,t.push(" "+s)),n=s}},i.prototype.getSymbolDisplay=function(e){return function(e){var t=typeof e;if("string"===t)return e;if("object"===t){if(e.literal)return JSON.stringify(e.literal);if(e instanceof RegExp)return"character matching "+e;if(e.type)return e.type+" token";if(e.test)return"token matching "+String(e.test);throw new Error("Unknown symbol type: "+e)}}(e)},i.prototype.buildFirstStateStack=function(e,t){if(-1!==t.indexOf(e))return null;if(0===e.wantedBy.length)return[e];var n=e.wantedBy[0],r=[e].concat(t),o=this.buildFirstStateStack(n,r);return null===o?null:[e].concat(o)},i.prototype.save=function(){var e=this.table[this.current];return e.lexerState=this.lexerState,e},i.prototype.restore=function(e){var t=e.index;this.current=t,this.table[t]=e,this.table.splice(t+1),this.lexerState=e.lexerState,this.results=this.finish()},i.prototype.rewind=function(e){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[e])},i.prototype.finish=function(){var e=[],t=this.grammar.start;return this.table[this.table.length-1].states.forEach((function(n){n.rule.name===t&&n.dot===n.rule.symbols.length&&0===n.reference&&n.data!==i.fail&&e.push(n)})),e.map((function(e){return e.data}))},{Parser:i,Grammar:r,Rule:e}},e.exports?e.exports=n():t.nearley=n()}));function We(){return(We=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function et(e){return e[0]}var tt=je((function(e){var t,n;t=Oe,n=function(){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n="boolean"==typeof(new RegExp).sticky;function r(e){return e&&"[object RegExp]"===t.call(e)}function o(e){return e&&"object"==typeof e&&!r(e)&&!Array.isArray(e)}function i(e){return e.length?"(?:"+e.map((function(e){return"(?:"+e+")"})).join("|")+")":"(?!)"}function s(e){if("string"==typeof e)return"(?:"+e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")+")";if(r(e)){if(e.ignoreCase)throw new Error("RegExp /i flag not allowed");if(e.global)throw new Error("RegExp /g flag is implied");if(e.sticky)throw new Error("RegExp /y flag is implied");if(e.multiline)throw new Error("RegExp /m flag is implied");return e.source}throw new Error("Not a pattern: "+e)}function a(t,n){if(o(n)||(n={match:n}),n.include)throw new Error("Matching rules cannot also include states");var i={defaultType:t,lineBreaks:!!n.error||!!n.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var s in n)e.call(n,s)&&(i[s]=n[s]);if("string"==typeof i.type&&t!==i.type)throw new Error("Type transform cannot be a string (type '"+i.type+"' for token '"+t+"')");var a=i.match;return i.match=Array.isArray(a)?a:a?[a]:[],i.match.sort((function(e,t){return r(e)&&r(t)?0:r(t)?-1:r(e)?1:t.length-e.length})),i}function l(e){return Array.isArray(e)?function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];if(r.include)for(var o=[].concat(r.include),i=0;i<o.length;i++)t.push({include:o[i]});else{if(!r.type)throw new Error("Rule has no type: "+JSON.stringify(r));t.push(a(r.type,r))}}return t}(e):function(e){for(var t=Object.getOwnPropertyNames(e),n=[],r=0;r<t.length;r++){var i=t[r],s=[].concat(e[i]);if("include"!==i){var l=[];s.forEach((function(e){o(e)?(l.length&&n.push(a(i,l)),n.push(a(i,e)),l=[]):l.push(e)})),l.length&&n.push(a(i,l))}else for(var u=0;u<s.length;u++)n.push({include:s[u]})}return n}(e)}var u=a("error",{lineBreaks:!0,shouldThrow:!0});function c(e,t){for(var o=null,a=Object.create(null),l=!0,c=null,f=[],p=[],h=0;h<e.length;h++)e[h].fallback&&(l=!1);for(h=0;h<e.length;h++){var d=e[h];if(d.include)throw new Error("Inheritance is not allowed in stateless lexers");if(d.error||d.fallback){if(o)throw!d.fallback==!o.fallback?new Error("Multiple "+(d.fallback?"fallback":"error")+" rules not allowed (for token '"+d.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+d.defaultType+"')");o=d}var m=d.match.slice();if(l)for(;m.length&&"string"==typeof m[0]&&1===m[0].length;)a[m.shift().charCodeAt(0)]=d;if(d.pop||d.push||d.next){if(!t)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+d.defaultType+"')");if(d.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+d.defaultType+"')")}if(0!==m.length){l=!1,f.push(d);for(var y=0;y<m.length;y++){var b=m[y];if(r(b))if(null===c)c=b.unicode;else if(c!==b.unicode&&!1===d.fallback)throw new Error("If one rule is /u then all must be")}var g=i(m.map(s)),v=new RegExp(g);if(v.test(""))throw new Error("RegExp matches empty string: "+v);if(new RegExp("|"+g).exec("").length-1>0)throw new Error("RegExp has capture groups: "+v+"\nUse (?: … ) instead");if(!d.lineBreaks&&v.test("\n"))throw new Error("Rule should declare lineBreaks: "+v);p.push("("+g+")")}}var w=o&&o.fallback,x=n&&!w?"ym":"gm",S=n||w?"":"|";return!0===c&&(x+="u"),{regexp:new RegExp(i(p)+S,x),groups:f,fast:a,error:o||u}}function f(e,t,n){var r=e&&(e.push||e.next);if(r&&!n[r])throw new Error("Missing state '"+r+"' (in token '"+e.defaultType+"' of state '"+t+"')");if(e&&e.pop&&1!=+e.pop)throw new Error("pop must be 1 (in token '"+e.defaultType+"' of state '"+t+"')")}var p=function(e,t){this.startState=t,this.states=e,this.buffer="",this.stack=[],this.reset()};p.prototype.reset=function(e,t){return this.buffer=e||"",this.index=0,this.line=t?t.line:1,this.col=t?t.col:1,this.queuedToken=t?t.queuedToken:null,this.queuedThrow=t?t.queuedThrow:null,this.setState(t?t.state:this.startState),this.stack=t&&t.stack?t.stack.slice():[],this},p.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},p.prototype.setState=function(e){if(e&&this.state!==e){this.state=e;var t=this.states[e];this.groups=t.groups,this.error=t.error,this.re=t.regexp,this.fast=t.fast}},p.prototype.popState=function(){this.setState(this.stack.pop())},p.prototype.pushState=function(e){this.stack.push(this.state),this.setState(e)};var h=n?function(e,t){return e.exec(t)}:function(e,t){var n=e.exec(t);return 0===n[0].length?null:n};function d(){return this.value}if(p.prototype._getGroup=function(e){for(var t=this.groups.length,n=0;n<t;n++)if(void 0!==e[n+1])return this.groups[n];throw new Error("Cannot find token type for matched text")},p.prototype.next=function(){var e=this.index;if(this.queuedGroup){var t=this._token(this.queuedGroup,this.queuedText,e);return this.queuedGroup=null,this.queuedText="",t}var n=this.buffer;if(e!==n.length){if(s=this.fast[n.charCodeAt(e)])return this._token(s,n.charAt(e),e);var r=this.re;r.lastIndex=e;var o=h(r,n),i=this.error;if(null==o)return this._token(i,n.slice(e,n.length),e);var s=this._getGroup(o),a=o[0];return i.fallback&&o.index!==e?(this.queuedGroup=s,this.queuedText=a,this._token(i,n.slice(e,o.index),e)):this._token(s,a,e)}},p.prototype._token=function(e,t,n){var r=0;if(e.lineBreaks){var o=/\n/g,i=1;if("\n"===t)r=1;else for(;o.exec(t);)r++,i=o.lastIndex}var s={type:"function"==typeof e.type&&e.type(t)||e.defaultType,value:"function"==typeof e.value?e.value(t):t,text:t,toString:d,offset:n,lineBreaks:r,line:this.line,col:this.col},a=t.length;if(this.index+=a,this.line+=r,0!==r?this.col=a-i+1:this.col+=a,e.shouldThrow)throw new Error(this.formatError(s,"invalid syntax"));return e.pop?this.popState():e.push?this.pushState(e.push):e.next&&this.setState(e.next),s},"undefined"!=typeof Symbol&&Symbol.iterator){var m=function(e){this.lexer=e};m.prototype.next=function(){var e=this.lexer.next();return{value:e,done:!e}},m.prototype[Symbol.iterator]=function(){return this},p.prototype[Symbol.iterator]=function(){return new m(this)}}return p.prototype.formatError=function(e,t){if(null==e){var n=this.buffer.slice(this.index);e={text:n,offset:this.index,lineBreaks:-1===n.indexOf("\n")?0:1,line:this.line,col:this.col}}var r=Math.max(0,e.offset-e.col+1),o=e.lineBreaks?e.text.indexOf("\n"):e.text.length,i=this.buffer.substring(r,e.offset+o);return t+=" at line "+e.line+" col "+e.col+":\n\n",(t+=" "+i+"\n")+" "+Array(e.col).join(" ")+"^"},p.prototype.clone=function(){return new p(this.states,this.state)},p.prototype.has=function(e){return!0},{compile:function(e){var t=c(l(e));return new p({start:t},"start")},states:function(e,t){var n=e.$all?l(e.$all):[];delete e.$all;var r=Object.getOwnPropertyNames(e);t||(t=r[0]);for(var o=Object.create(null),i=0;i<r.length;i++)o[v=r[i]]=l(e[v]).concat(n);for(i=0;i<r.length;i++)for(var s=o[v=r[i]],a=Object.create(null),u=0;u<s.length;u++){var h=s[u];if(h.include){var d=[u,1];if(h.include!==v&&!a[h.include]){a[h.include]=!0;var m=o[h.include];if(!m)throw new Error("Cannot include nonexistent state '"+h.include+"' (in state '"+v+"')");for(var y=0;y<m.length;y++){var b=m[y];-1===s.indexOf(b)&&d.push(b)}}s.splice.apply(s,d),u--}}var g=Object.create(null);for(i=0;i<r.length;i++){var v;g[v=r[i]]=c(o[v],!0)}for(i=0;i<r.length;i++){var w=r[i],x=g[w],S=x.groups;for(u=0;u<S.length;u++)f(S[u],w,g);var k=Object.getOwnPropertyNames(x.fast);for(u=0;u<k.length;u++)f(x.fast[k[u]],w,g)}return new p(g,t)},error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:function(e){for(var t=Object.create(null),n=Object.create(null),r=Object.getOwnPropertyNames(e),o=0;o<r.length;o++){var i=r[o],s=e[i];(Array.isArray(s)?s:[s]).forEach((function(e){if((n[e.length]=n[e.length]||[]).push(e),"string"!=typeof e)throw new Error("keyword must be string (in keyword '"+i+"')");t[e]=i}))}function a(e){return JSON.stringify(e)}var l="";for(var u in l+="switch (value.length) {\n",n)l+="case "+u+":\n",l+="switch (value) {\n",n[u].forEach((function(e){var n=t[e];l+="case "+a(e)+": return "+a(n)+"\n"})),l+="}\n";return l+="}\n",Function("value",l)}}},e.exports?e.exports=n():t.moo=n()})).compile({whitespace:{match:/\s+/,lineBreaks:!0},lineComment:{match:/\/\/.*?\n?$/},hexadecimal:r.hexadecimal,octal:r.octal,measurement:r.measurement,decimal:r.decimal,integer:r.integer,taggedString:{match:r.taggedString},boolean:["true","TRUE","True","false","FALSE","False"],symbol:r.symbol,identifier:r.identifier,doubleQuotedString:{match:r.doubleQuotedString,value:function(e){return e.slice(1,-1)}},singleQuotedString:{match:r.singleQuotedString,value:function(e){return e.slice(1,-1)}},tickedString:{match:r.tickedString,value:function(e){return e.slice(1,-1)}},"--\x3e":"--\x3e","--":"--","<--":"<--","-[]->":"-[]->","-[]-":"-[]-","<-[]-":"<-[]-","<-[":"<-[","]->":"]->","-[":"-[","]-":"]-","{":"{","}":"}","[":"[","]":"]","(":"(",")":")",",":",",":":":","`":"`","'":"'","ø":"ø"}),nt=function(){return null},rt=function(e){return e[0].text},ot={Lexer:tt,ParserRules:[{name:"GramSeq$ebnf$1$subexpression$1",symbols:["Path","_"],postprocess:function(e){return e[0]}},{name:"GramSeq$ebnf$1",symbols:["GramSeq$ebnf$1$subexpression$1"]},{name:"GramSeq$ebnf$1$subexpression$2",symbols:["Path","_"],postprocess:function(e){return e[0]}},{name:"GramSeq$ebnf$1",symbols:["GramSeq$ebnf$1","GramSeq$ebnf$1$subexpression$2"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"GramSeq$ebnf$2",symbols:["EOL"],postprocess:et},{name:"GramSeq$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"GramSeq",symbols:["GramSeq$ebnf$1","GramSeq$ebnf$2"],postprocess:function(e){return N.seq(N.flatten(e[0]))}},{name:"Path",symbols:["NodePattern"],postprocess:et},{name:"Path",symbols:["PathComposition"],postprocess:et},{name:"Path",symbols:["PathPair"],postprocess:et},{name:"NodePattern",symbols:["Node","_","Edge","_","NodePattern"],postprocess:function(e){var t=e[2];return N.cons([e[0],e[4]],{kind:t.kind,id:t.id,labels:t.labels,record:t.record})}},{name:"NodePattern",symbols:["Node"],postprocess:et},{name:"Node",symbols:[{literal:"("},"_","Attributes","_",{literal:")"}],postprocess:function(e){var t=e[2];return N.node(t.id,t.labels,t.record)}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]->"}],postprocess:function(e){return We({kind:"right"},e[2])}},{name:"Edge",symbols:[{literal:"-["},"_","Attributes",{literal:"]-"}],postprocess:function(e){return We({kind:"either"},e[2])}},{name:"Edge",symbols:[{literal:"<-["},"_","Attributes",{literal:"]-"}],postprocess:function(e){return We({kind:"left"},e[2])}},{name:"Edge",symbols:[{literal:"-[]->"}],postprocess:function(){return{kind:"right"}}},{name:"Edge",symbols:[{literal:"-[]-"}],postprocess:function(){return{kind:"either"}}},{name:"Edge",symbols:[{literal:"<-[]-"}],postprocess:function(){return{kind:"left"}}},{name:"Edge",symbols:[{literal:"--\x3e"}],postprocess:function(){return{kind:"right"}}},{name:"Edge",symbols:[{literal:"--"}],postprocess:function(){return{kind:"either"}}},{name:"Edge",symbols:[{literal:"<--"}],postprocess:function(){return{kind:"left"}}},{name:"PathComposition",symbols:["PathPoint"],postprocess:et},{name:"PathComposition",symbols:["PathAnnotation"],postprocess:et},{name:"PathComposition",symbols:["PathExpression"],postprocess:et},{name:"PathPoint",symbols:[{literal:"["},"_","Attributes","_",{literal:"]"}],postprocess:function(e){var t=e[2];return(t.id||t.labels||t.record)&&"ø"!==t.id?N.node(t.id,t.labels,t.record):N.empty()}},{name:"PathAnnotation",symbols:[{literal:"["},"_","Attributes","_","Path",{literal:"]"}],postprocess:function(e){var t=e[2];return N.cons([e[4]],{id:t.id,labels:t.labels,record:t.record})}},{name:"PathExpression$ebnf$1",symbols:["Kind"],postprocess:et},{name:"PathExpression$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"PathExpression",symbols:[{literal:"["},"_","Attributes","_","PathExpression$ebnf$1","_","Path","_","Path","_",{literal:"]"}],postprocess:function(e){var t=e[2];return N.cons([e[6],e[8]],{kind:e[4],id:t.id,labels:t.labels,record:t.record})}},{name:"PathPair$subexpression$1",symbols:["NodePattern"]},{name:"PathPair$subexpression$1",symbols:["PathComposition"]},{name:"PathPair",symbols:["PathPair$subexpression$1","_",{literal:","},"_","Path"],postprocess:function(e){return N.pair([e[0][0],e[4]])}},{name:"Kind",symbols:[{literal:","}],postprocess:function(){return"pair"}},{name:"Kind",symbols:[{literal:"--\x3e"}],postprocess:function(){return"right"}},{name:"Kind",symbols:[{literal:"--"}],postprocess:function(){return"either"}},{name:"Kind",symbols:[{literal:"<--"}],postprocess:function(){return"left"}},{name:"Attributes$ebnf$1",symbols:["Identity"],postprocess:et},{name:"Attributes$ebnf$1",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$2$subexpression$1",symbols:["_","LabelList"],postprocess:function(e){return e[1]}},{name:"Attributes$ebnf$2",symbols:["Attributes$ebnf$2$subexpression$1"],postprocess:et},{name:"Attributes$ebnf$2",symbols:[],postprocess:function(){return null}},{name:"Attributes$ebnf$3$subexpression$1",symbols:["_","Record"],postprocess:function(e){return e[1]}},{name:"Attributes$ebnf$3",symbols:["Attributes$ebnf$3$subexpression$1"],postprocess:et},{name:"Attributes$ebnf$3",symbols:[],postprocess:function(){return null}},{name:"Attributes",symbols:["Attributes$ebnf$1","Attributes$ebnf$2","Attributes$ebnf$3"],postprocess:function(e){return{id:e[0],labels:e[1],record:e[2]}}},{name:"LabelList$ebnf$1",symbols:["Label"]},{name:"LabelList$ebnf$1",symbols:["LabelList$ebnf$1","Label"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"LabelList",symbols:["LabelList$ebnf$1"],postprocess:function(e){return e[0]}},{name:"Label",symbols:[{literal:":"},"Symbol"],postprocess:function(e){return e[1]}},{name:"Identity",symbols:[tt.has("identifier")?{type:"identifier"}:identifier],postprocess:rt},{name:"Identity",symbols:[{literal:"ø"}],postprocess:rt},{name:"Identity",symbols:[tt.has("symbol")?{type:"symbol"}:symbol],postprocess:rt},{name:"Identity",symbols:[tt.has("integer")?{type:"integer"}:integer],postprocess:rt},{name:"Identity",symbols:[tt.has("octal")?{type:"octal"}:octal],postprocess:rt},{name:"Identity",symbols:[tt.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:rt},{name:"Identity",symbols:[tt.has("measurement")?{type:"measurement"}:measurement],postprocess:rt},{name:"Identity",symbols:[tt.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return e[0].text.slice(1,-1)}},{name:"Symbol",symbols:[tt.has("symbol")?{type:"symbol"}:symbol],postprocess:rt},{name:"Symbol",symbols:[tt.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return e[0].text.slice(1,-1)}},{name:"Record",symbols:[{literal:"{"},"_",{literal:"}"}],postprocess:nt},{name:"Record$ebnf$1",symbols:[]},{name:"Record$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","Property"]},{name:"Record$ebnf$1",symbols:["Record$ebnf$1","Record$ebnf$1$subexpression$1"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"Record",symbols:[{literal:"{"},"_","Property","Record$ebnf$1","_",{literal:"}"}],postprocess:function(e){return[e[2]].concat(e[3].map((function(e){return e[3]})))}},{name:"Property",symbols:["Symbol","_",{literal:":"},"_","Value"],postprocess:function(e){return N.property(e[0],e[4])}},{name:"Value",symbols:["StringLiteral"],postprocess:et},{name:"Value",symbols:["NumericLiteral"],postprocess:et},{name:"Value",symbols:[tt.has("boolean")?{type:"boolean"}:boolean],postprocess:function(e){return N.boolean(JSON.parse(e[0].value.toLowerCase()))}},{name:"Value$ebnf$1",symbols:[]},{name:"Value$ebnf$1$subexpression$1",symbols:["_",{literal:","},"_","Value"]},{name:"Value$ebnf$1",symbols:["Value$ebnf$1","Value$ebnf$1$subexpression$1"],postprocess:function(e){return e[0].concat([e[1]])}},{name:"Value",symbols:[{literal:"["},"_","Value","Value$ebnf$1",{literal:"]"}],postprocess:function(e){return[e[2]].concat(e[3].map((function(e){return e[3]})))}},{name:"StringLiteral",symbols:[tt.has("singleQuotedString")?{type:"singleQuotedString"}:singleQuotedString],postprocess:function(e){return N.string(e[0].value)}},{name:"StringLiteral",symbols:[tt.has("doubleQuotedString")?{type:"doubleQuotedString"}:doubleQuotedString],postprocess:function(e){return N.string(e[0].value)}},{name:"StringLiteral",symbols:[tt.has("tickedString")?{type:"tickedString"}:tickedString],postprocess:function(e){return N.string(e[0].value)}},{name:"StringLiteral",symbols:[tt.has("taggedString")?{type:"taggedString"}:taggedString],postprocess:function(e){var t=function(e){var t=e.match(/([^`]+)`(.+)`$/);if(null==t)throw Error("Malformed tagged string: "+e);return{tag:t[1],value:t[2]}}(e[0].value);return N.tagged(t.tag,t.value)}},{name:"NumericLiteral",symbols:[tt.has("integer")?{type:"integer"}:integer],postprocess:function(e){return N.integer(e[0].value)}},{name:"NumericLiteral",symbols:[tt.has("decimal")?{type:"decimal"}:decimal],postprocess:function(e){return N.decimal(e[0].value)}},{name:"NumericLiteral",symbols:[tt.has("hexadecimal")?{type:"hexadecimal"}:hexadecimal],postprocess:function(e){return N.hexadecimal(e[0].value)}},{name:"NumericLiteral",symbols:[tt.has("octal")?{type:"octal"}:octal],postprocess:function(e){return N.octal(e[0].value)}},{name:"NumericLiteral",symbols:[tt.has("measurement")?{type:"measurement"}:measurement],postprocess:function(e){var t=function(e){var t=e.match(/(-?[0-9.]+)([a-zA-Z]+)/);if(null==t)throw Error("Malformed measurement : "+e);return{value:t[1],unit:t[2]}}(e[0].value);return N.measurement(t.unit,t.value)}},{name:"_",symbols:[]},{name:"_",symbols:[tt.has("whitespace")?{type:"whitespace"}:whitespace],postprocess:nt},{name:"Comment",symbols:[tt.has("lineComment")?{type:"lineComment"}:lineComment],postprocess:nt},{name:"EOL",symbols:[{literal:"\n"}],postprocess:nt}],ParserStart:"GramSeq"},it=function(e,t){var n,r,o=new Ye.Parser(Ye.Grammar.fromCompiled(ot));try{var i=o.feed(e);if(void 0===i.results[0]&&i.lexerState){var s={line:(r=i.lexerState).line,column:r.col};t.fail("Incomplete parse.",s)}return i.results.length>1&&t.info("[WARN] parsing is ambiguous"),i.results[0]||{type:"error"}}catch(e){var a=e.token?{line:(n=e.token).line,column:n.col}:{line:0,column:0};t.fail(e.message,a)}},st=function(){this.Parser=it};function at(){return!0}var lt=ut;function ut(e,t,n,r){var o,i;"function"==typeof t&&"function"!=typeof n&&(r=n,n=t,t=null),i=function e(t){if(null==t)return at;if("string"==typeof t)return function(e){return function(t){return t&&t.type===e}}(t);if("object"==typeof t)return"length"in t?function(t){for(var n=[],r=-1;++r<t.length;)n[r]=e(t[r]);return function(){for(var e=-1;++e<n.length;)if(n[e].apply(this,arguments))return!0}}(t):function(e){return function(t){var n;for(n in e)if(t[n]!==e[n])return;return!0}}(t);if("function"==typeof t)return t;throw new Error("Expected function, string, or object as test")}(t),o=r?-1:1,function e(s,a,l){var u,c="object"==typeof s&&null!==s?s:{};return"string"==typeof c.type&&(f.displayName="node ("+c.type+((u="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0)?"<"+u+">":"")+")"),f;function f(){var u,c,f=l.concat(s),p=[];if((!t||i(s,a,l[l.length-1]||null))&&!1===(p=function(e){return null!==e&&"object"==typeof e&&"length"in e?e:"number"==typeof e?[!0,e]:[e]}(n(s,l)))[0])return p;if(s.children&&"skip"!==p[0])for(c=(r?s.children.length:-1)+o;c>-1&&c<s.children.length;){if(!1===(u=e(s.children[c],c,f)())[0])return u;c="number"==typeof u[1]?u[1]:c+o}return p}}(e,null,[])()}ut.CONTINUE=!0,ut.SKIP="skip",ut.EXIT=!1;var ct=ht,ft=lt.SKIP,pt=lt.EXIT;function ht(e,t,n,r){"function"==typeof t&&"function"!=typeof n&&(r=n,n=t,t=null),lt(e,t,(function(e,t){var r=t[t.length-1],o=r?r.children.indexOf(e):null;return n(e,o,r)}),r)}ht.CONTINUE=lt.CONTINUE,ht.SKIP=ft,ht.EXIT=pt;let dt=e=>crypto.getRandomValues(new Uint8Array(e));function mt(){return(mt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var yt={generator:"counter",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",prefix:void 0},bt=[function(e){var t=mt({},yt,e);return function(e){var n,r,i;switch(t.generator){case"nanoid":n=function(e,t,n){void 0===e&&(e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"),void 0===t&&(t=21);var r=((e,t)=>((e,t,n)=>{let r=(2<<Math.log(e.length-1)/Math.LN2)-1,o=-~(1.6*r*t/e.length);return()=>{let i="";for(;;){let s=n(o),a=o;for(;a--;)if(i+=e[s[a]&r]||"",i.length===+t)return i}}})(e,t,dt))(e,t);return{generate:function(){return n?n+r():r()}}}(t.alphabet,21,t.prefix);break;case"counter":default:r=t.prefix,i=0,n={generate:function(){return""+(r||"")+i++}}}ct(e,(function(e){o(e)&&(e.id=e.id||n.generate())}))}}],gt={plugins:bt},vt={__proto__:null,default:gt,__moduleExports:gt,plugins:bt},wt=Ue().use(st).use(vt),xt=function(e){var t=wt.runSync(wt.parse(e));return{nodes:R(t).map(St),links:q(t).map(kt),paths:[]}},St=function(e){return s(e)?M(e.id,e.labels,e.record):M("random")},kt=function(e){return B(function(e){return"left"===e.kind?e.children[1].id||G:e.children[0].id||G}(e),function(e){return"left"===e.kind?e.children[0].id||G:e.children[1].id||G}(e),e.id,e.labels,e.record)};e.MISSING_ID=G,e.d3Gram=xt,e.default=xt,e.edgeToD3=kt,e.isGramNodeDatum=function(e){return void 0!==e.id},e.makeGramLinkDatum=B,e.makeGramNodeDatum=M,e.nodeToD3=St,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=d3-gram.umd.production.min.js.map

@@ -15,3 +15,3 @@ {

},
"version": "0.1.19",
"version": "0.1.20",
"author": "Andreas Kollegger",

@@ -35,3 +35,3 @@ "license": "MIT",

"start": "tsdx watch",
"build": "tsdx build --format umd,esm,cjs --tsconfig tsconfig.build.json",
"build": "tsdx build --format umd,esm,cjs",
"test": "tsdx test",

@@ -57,4 +57,4 @@ "test:watch": "tsdx test --watch",

"devDependencies": {
"@gram-data/gram-builder": "^0.2.13",
"@gram-data/gram-stringify": "^0.2.14",
"@gram-data/gram-builder": "^0.2.15",
"@gram-data/gram-stringify": "^0.2.17",
"@types/d3": "^6.2.0",

@@ -78,8 +78,8 @@ "@types/jest": "^26.0.15",

"dependencies": {
"@gram-data/gram-ast": "^0.2.13",
"@gram-data/gram-ops": "^0.2.14",
"@gram-data/gram-parse": "^0.2.14",
"@gram-data/gram-preset-basic": "^0.2.13"
"@gram-data/gram-ast": "^0.2.15",
"@gram-data/gram-ops": "^0.2.17",
"@gram-data/gram-parse": "^0.2.17",
"@gram-data/gram-preset-basic": "^0.2.17"
},
"gitHead": "a255da2f7cfa6bd16f637d1241d17e10510e60c0"
}

@@ -13,5 +13,5 @@ import { edges, nodes } from '@gram-data/gram-ops';

const unified = require('unified');
const gramParserPlugin = require('@gram-data/gram-parse').gramParserPlugin;
const gramPresetBasic = require('@gram-data/gram-preset-basic');
import unified from 'unified';
import { gramParserPlugin } from '@gram-data/gram-parse';
import * as gramPresetBasic from '@gram-data/gram-preset-basic';

@@ -29,10 +29,8 @@ const gramProcessor = unified()

export const d3Gram = (src: string): GramGraphData => {
const parsed = gramProcessor.runSync(gramProcessor.parse(src));
const parsed: GramPath = gramProcessor.runSync(
gramProcessor.parse(src)
) as GramPath;
const d3Gram = {
nodes: (nodes(parsed) as GramNode[]).map(nodeToD3),
links: parsed.children.reduce(
(acc: GramLinkDatum[], p: GramPath) =>
acc.concat((edges(p) as GramEdge[]).map(edgeToD3)),
[] as GramLinkDatum[]
),
links: (edges(parsed) as GramEdge[]).map(edgeToD3),
paths: [] as GramPathDatum[],

@@ -39,0 +37,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc