@podlite/schema 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +36 -4
  2. package/LICENSE +1 -1
  3. package/README.md +40 -0
  4. package/lib/ast-helpers.d.ts +1 -1
  5. package/lib/ast-helpers.js +2 -1
  6. package/lib/ast-inerator.d.ts +0 -1
  7. package/lib/ast-inerator.js +7 -15
  8. package/lib/blocks-helpers.d.ts +1 -1
  9. package/lib/blocks-helpers.js +15 -12
  10. package/lib/exportAny.d.ts +19 -0
  11. package/lib/exportAny.js +72 -0
  12. package/lib/exportHtml.d.ts +15 -0
  13. package/lib/exportHtml.js +284 -0
  14. package/lib/grammar.d.ts +14 -0
  15. package/lib/grammar.js +6396 -0
  16. package/lib/grammarfc.d.ts +14 -0
  17. package/lib/grammarfc.js +3363 -0
  18. package/lib/helpers/config.d.ts +12 -0
  19. package/lib/helpers/config.js +56 -0
  20. package/lib/helpers/corePlugins.d.ts +12 -0
  21. package/lib/helpers/corePlugins.js +26 -0
  22. package/lib/helpers/handlers.d.ts +47 -0
  23. package/lib/helpers/handlers.js +120 -0
  24. package/lib/helpers/ids.d.ts +18 -0
  25. package/lib/helpers/ids.js +74 -0
  26. package/lib/helpers/makeInterator.d.ts +5 -0
  27. package/lib/helpers/makeInterator.js +54 -0
  28. package/lib/helpers/makeQuery.d.ts +47 -0
  29. package/lib/helpers/makeQuery.js +107 -0
  30. package/lib/helpers/makeQuery.test.d.ts +1 -0
  31. package/lib/helpers/makeQuery.test.js +51 -0
  32. package/lib/helpers/makeTransformer.d.ts +7 -0
  33. package/lib/helpers/makeTransformer.js +67 -0
  34. package/lib/helpers/plugins.d.ts +2 -0
  35. package/lib/helpers/plugins.js +27 -0
  36. package/lib/index.d.ts +64 -0
  37. package/lib/index.js +85 -5
  38. package/lib/pluggableParser.d.ts +27 -0
  39. package/lib/pluggableParser.js +80 -0
  40. package/lib/plugin-clean-location.d.ts +2 -0
  41. package/lib/plugin-clean-location.js +26 -0
  42. package/lib/plugin-defn-fill-term.d.ts +2 -0
  43. package/lib/plugin-defn-fill-term.js +55 -0
  44. package/lib/plugin-formatting-codes.d.ts +3 -0
  45. package/lib/plugin-formatting-codes.js +76 -0
  46. package/lib/plugin-group-defn.d.ts +2 -0
  47. package/lib/plugin-group-defn.js +73 -0
  48. package/lib/plugin-group-items.d.ts +2 -0
  49. package/lib/plugin-group-items.js +84 -0
  50. package/lib/plugin-heading.d.ts +2 -0
  51. package/lib/plugin-heading.js +35 -0
  52. package/lib/plugin-items.d.ts +2 -0
  53. package/lib/plugin-items.js +43 -0
  54. package/lib/plugin-tables.d.ts +5 -0
  55. package/lib/plugin-tables.js +146 -0
  56. package/lib/plugin-vmargin.d.ts +3 -0
  57. package/lib/plugin-vmargin.js +31 -0
  58. package/lib/query-helpers.d.ts +2 -1
  59. package/lib/query-helpers.js +10 -10
  60. package/lib/types.d.ts +69 -69
  61. package/lib/types.js +1 -0
  62. package/lib/writer.d.ts +30 -0
  63. package/lib/writer.js +106 -0
  64. package/lib/writerHtml.d.ts +11 -0
  65. package/lib/writerHtml.js +34 -0
  66. package/package.json +18 -10
  67. package/schema/index.d.ts +3 -3
  68. package/index.js +0 -2
  69. package/lib/helpers.d.ts +0 -1
  70. package/lib/helpers.js +0 -5
@@ -0,0 +1,12 @@
1
+ export declare type Context = {
2
+ config?: any;
3
+ };
4
+ export interface Attr {
5
+ getAllValues: (name: any) => any;
6
+ getFirstValue: (name: any) => any;
7
+ asHash: () => {};
8
+ (): {};
9
+ exists(name: string): boolean;
10
+ }
11
+ export declare const makeAttrs: (node: any, ctx?: Context) => Attr;
12
+ export default makeAttrs;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeAttrs = void 0;
4
+ const makeAttrs = (node, ctx = {}) => {
5
+ const config = node.config instanceof Array ? node.config : [];
6
+ // add config's from ctx
7
+ let configured = [];
8
+ if (ctx.config && ctx.config.hasOwnProperty(node.name)) {
9
+ configured = ctx.config[node.name];
10
+ }
11
+ let result = {};
12
+ [...config, ...configured].map(a => {
13
+ if (!result.hasOwnProperty(a.name)) {
14
+ result[a.name] = [];
15
+ }
16
+ if (a.type === 'array') {
17
+ result[a.name].push(...a.value);
18
+ }
19
+ else {
20
+ result[a.name].push(a.value);
21
+ }
22
+ });
23
+ let resfn = function () { };
24
+ /**
25
+ * check if prop exists
26
+ *
27
+ * for example: attrs.exists('caption')
28
+ */
29
+ resfn.exists = name => result.hasOwnProperty(name);
30
+ /**
31
+ * return array for prop
32
+ *
33
+ * for example: attrs.getAllValues('caption')
34
+ */
35
+ resfn.getAllValues = name => {
36
+ return resfn.exists(name) ? result[name] : [];
37
+ };
38
+ /**
39
+ * return first value or undefined if prop don't exists
40
+ *
41
+ * for example: attrs.exists('caption')
42
+ */
43
+ resfn.getFirstValue = name => {
44
+ return resfn.exists(name) ? resfn.getAllValues(name)[0] : undefined;
45
+ };
46
+ /**
47
+ * return key: val
48
+ *
49
+ * for example: attrs.asHash()
50
+ */
51
+ resfn.asHash = () => result;
52
+ return resfn;
53
+ };
54
+ exports.makeAttrs = makeAttrs;
55
+ exports.default = exports.makeAttrs;
56
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,12 @@
1
+ export declare const core: {
2
+ ':image': {
3
+ toHtml: (writer: any) => (node: any) => void;
4
+ };
5
+ image: {
6
+ toHtml: import("./makeQuery").RuleHandler<any>;
7
+ };
8
+ root: {
9
+ toHtml: import("./makeQuery").RuleHandler<any>;
10
+ };
11
+ };
12
+ export default core;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.core = void 0;
4
+ const __1 = require("..");
5
+ exports.core = {
6
+ ':image': {
7
+ toHtml: writer => node => {
8
+ if (typeof node !== 'string' && 'type' in node && node.type === 'image') {
9
+ writer.writeRaw(`<img`);
10
+ writer.writeRaw(` src="${node.src}"`);
11
+ if (node.alt) {
12
+ writer.writeRaw(` alt="${node.alt}"`);
13
+ }
14
+ writer.writeRaw(`/>`);
15
+ }
16
+ },
17
+ },
18
+ image: {
19
+ toHtml: __1.content,
20
+ },
21
+ root: {
22
+ toHtml: __1.content,
23
+ },
24
+ };
25
+ exports.default = exports.core;
26
+ //# sourceMappingURL=corePlugins.js.map
@@ -0,0 +1,47 @@
1
+ import { RuleObject, RuleHandler } from './makeQuery';
2
+ /**
3
+ * wrap content by open and closed tags
4
+ */
5
+ export declare const wrapContent: (pre: any, post: any) => RuleHandler;
6
+ /**
7
+ * emptyContent - skip any child node
8
+ */
9
+ export declare const emptyContent: () => RuleHandler;
10
+ /**
11
+ * content - process childs as regular content
12
+ */
13
+ export declare const content: RuleHandler;
14
+ /**
15
+
16
+ Set hander after call with node
17
+
18
+ ':para':setFn((node,ctx) => (ctx.parents || [] ).includes('head') ? content : wrapContent('<p>','</p>'),
19
+
20
+ */
21
+ export declare const setFn: (check: any) => RuleHandler;
22
+ /**
23
+
24
+ Set new context for handler
25
+
26
+ const parents = (ctx.parents || [])
27
+ parents.push('head')
28
+ const {level} = node
29
+ return setContext( { ...ctx, parents }, wrapContent(`<h${level}>`,`</h${level}>`))
30
+
31
+ */
32
+ export declare const setContext: (ctx: any, fn: any) => RuleHandler;
33
+ /**
34
+ * Make subset of rules for processing
35
+ *
36
+ * @param {*} rules
37
+ * @param {*} processNode
38
+ */
39
+ export declare const subUse: (rules: RuleObject | Array<RuleObject>, processNode: any) => RuleHandler;
40
+ /**
41
+ * Add support nesting
42
+ *
43
+ * @param {*} rules
44
+ * @param {*} implicitLevel - default level of nesting
45
+ *
46
+ */
47
+ export declare const handleNested: (defaultHandler: RuleHandler, implicitLevel?: number) => RuleHandler;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.handleNested = exports.subUse = exports.setContext = exports.setFn = exports.content = exports.emptyContent = exports.wrapContent = void 0;
7
+ const makeQuery_1 = require("./makeQuery");
8
+ const makeInterator_1 = __importDefault(require("./makeInterator"));
9
+ const config_1 = __importDefault(require("./config"));
10
+ /**
11
+ * wrap content by open and closed tags
12
+ */
13
+ const wrapContent = (pre, post) => (writer, processor) => (node, ctx, interator) => {
14
+ writer.writeRaw(pre);
15
+ if (node.content)
16
+ interator(node.content, ctx);
17
+ writer.writeRaw(post);
18
+ };
19
+ exports.wrapContent = wrapContent;
20
+ /**
21
+ * emptyContent - skip any child node
22
+ */
23
+ const emptyContent = () => () => () => { };
24
+ exports.emptyContent = emptyContent;
25
+ /**
26
+ * content - process childs as regular content
27
+ */
28
+ const content = (writer, processor) => (node, ctx, interator) => {
29
+ if (node.content) {
30
+ return interator(node.content, ctx);
31
+ }
32
+ };
33
+ exports.content = content;
34
+ /**
35
+
36
+ Set hander after call with node
37
+
38
+ ':para':setFn((node,ctx) => (ctx.parents || [] ).includes('head') ? content : wrapContent('<p>','</p>'),
39
+
40
+ */
41
+ const setFn = (check) => (writer, processor) => {
42
+ return (node, ctx, interator) => {
43
+ return check(node, ctx)(writer, processor)(node, ctx, interator);
44
+ };
45
+ };
46
+ exports.setFn = setFn;
47
+ /**
48
+
49
+ Set new context for handler
50
+
51
+ const parents = (ctx.parents || [])
52
+ parents.push('head')
53
+ const {level} = node
54
+ return setContext( { ...ctx, parents }, wrapContent(`<h${level}>`,`</h${level}>`))
55
+
56
+ */
57
+ const setContext = (ctx, fn) => (writer, processor) => {
58
+ return (node, _, interator) => {
59
+ return fn(writer, processor)(node, ctx, interator);
60
+ };
61
+ };
62
+ exports.setContext = setContext;
63
+ /**
64
+ * Select handler from already inited wrappers
65
+ *
66
+ * @param {*} check
67
+ * @param {...any} fns
68
+ */
69
+ const IfNode = (check, ...fns) => (writer, processor) => {
70
+ return (node, ctx, interator) => {
71
+ check(node, ctx, ...fns.map(i => i(writer, processor)))(node, ctx, interator);
72
+ };
73
+ };
74
+ /**
75
+ * Make subset of rules for processing
76
+ *
77
+ * @param {*} rules
78
+ * @param {*} processNode
79
+ */
80
+ const subUse = (rules, processNode) => {
81
+ const newFns = (0, makeQuery_1.makeRulesArray)(rules).reverse();
82
+ return (writer, processor) => {
83
+ // init new rules
84
+ const inited = newFns.map(item => (0, makeQuery_1.makeRule)(item.rule, item.fn(writer, processor))).reverse();
85
+ const processNodeInited = processNode(writer, processor);
86
+ let subInterator;
87
+ return (node, ctx, interator) => {
88
+ if (!subInterator)
89
+ subInterator = (0, makeInterator_1.default)([...interator.rules, ...inited]);
90
+ return processNodeInited(node, ctx, subInterator);
91
+ };
92
+ };
93
+ };
94
+ exports.subUse = subUse;
95
+ /**
96
+ * Add support nesting
97
+ *
98
+ * @param {*} rules
99
+ * @param {*} implicitLevel - default level of nesting
100
+ *
101
+ */
102
+ const handleNested = (defaultHandler, implicitLevel) => {
103
+ return (writer, processor) => {
104
+ const defaultHandlerInited = defaultHandler(writer, processor);
105
+ return (node, ctx, interator) => {
106
+ const nesting = (0, config_1.default)(node, ctx).getFirstValue('nested') || implicitLevel;
107
+ // add nesting level
108
+ if (nesting !== undefined) {
109
+ writer.addLevel(nesting);
110
+ }
111
+ defaultHandlerInited(node, ctx, interator);
112
+ // remove nesting level
113
+ if (nesting !== undefined) {
114
+ writer.removeLevel(nesting);
115
+ }
116
+ };
117
+ };
118
+ };
119
+ exports.handleNested = handleNested;
120
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1,18 @@
1
+ import { ParserPlugin } from '..';
2
+ /**
3
+ * Clean ids from tree
4
+ * @returns
5
+ */
6
+ export declare const cleanIds: (src?: {
7
+ skipChain: number;
8
+ podMode: number;
9
+ }) => (tree: any) => any;
10
+ /**
11
+ * Add set id to 'id' to each blocks
12
+ */
13
+ export declare const frozenIds: (src?: {
14
+ skipChain: number;
15
+ podMode: number;
16
+ }) => (tree: any) => any;
17
+ declare const middleware: ParserPlugin;
18
+ export default middleware;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.frozenIds = exports.cleanIds = void 0;
4
+ const __1 = require("..");
5
+ const nanoid_1 = require("nanoid");
6
+ /**
7
+ * Clean ids from tree
8
+ * @returns
9
+ */
10
+ const cleanIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
11
+ const transformerBlocks = (0, __1.makeTransformer)({
12
+ '*': (node, ctx, visiter) => {
13
+ if ('id' in node) {
14
+ if ('content' in node) {
15
+ node.content = visiter(node.content, ctx);
16
+ }
17
+ const { id, ...rest } = node;
18
+ return { ...rest };
19
+ }
20
+ return node;
21
+ },
22
+ });
23
+ return transformerBlocks(tree, {});
24
+ };
25
+ exports.cleanIds = cleanIds;
26
+ /**
27
+ * Add set id to 'id' to each blocks
28
+ */
29
+ const frozenIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
30
+ const transformerBlocks = (0, __1.makeTransformer)({
31
+ '*': (node, ctx, visiter) => {
32
+ if ('id' in node) {
33
+ if ('content' in node) {
34
+ node.content = visiter(node.content, ctx);
35
+ }
36
+ const { id, ...rest } = node;
37
+ return { ...rest, id: 'id' };
38
+ }
39
+ return node;
40
+ },
41
+ });
42
+ return transformerBlocks(tree, {});
43
+ };
44
+ exports.frozenIds = frozenIds;
45
+ const middleware = () => tree => {
46
+ const transformerBlocks = (0, __1.makeTransformer)({
47
+ '*': (node, ctx, visiter) => {
48
+ const addIdField = (node) => {
49
+ if (typeof node === 'object' && 'type' in node && node.type == 'block') {
50
+ if (node.name == 'caption') {
51
+ return node;
52
+ }
53
+ else if (node.name == 'head') {
54
+ return { ...node, id: (0, __1.getTextContentFromNode)(node).trim() };
55
+ }
56
+ else {
57
+ return { ...node, id: (0, nanoid_1.nanoid)() };
58
+ }
59
+ }
60
+ return node;
61
+ };
62
+ const processContent = (node) => {
63
+ if (typeof node === 'object' && 'content' in node) {
64
+ return { ...node, content: visiter(node.content, ctx) };
65
+ }
66
+ return node;
67
+ };
68
+ return processContent(addIdField(node));
69
+ },
70
+ });
71
+ return transformerBlocks(tree, {});
72
+ };
73
+ exports.default = middleware;
74
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1,5 @@
1
+ declare function thisFunc(rules: any): {
2
+ (node: any, context: any): any;
3
+ rules: any;
4
+ };
5
+ export default thisFunc;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function flattenDeep(arr) {
4
+ if (!Array.isArray(arr)) {
5
+ return arr;
6
+ }
7
+ return arr.reduce((acc, val) => (Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val)), []);
8
+ }
9
+ function thisFunc(rules) {
10
+ function interator(node, context) {
11
+ if (node instanceof Array) {
12
+ // filter null and undefined nodes
13
+ return flattenDeep(node.map(item => interator(item, context))).filter(Boolean);
14
+ }
15
+ if ('string' === typeof node) {
16
+ // convert string to lex node with type
17
+ return interator({ type: 'text', value: node }, context);
18
+ }
19
+ // get first rule for this node
20
+ const reversed = rules.slice();
21
+ reversed.reverse();
22
+ const ruleIndex = reversed.findIndex(rule => rule.isFor(node));
23
+ if (ruleIndex !== -1) {
24
+ // try to find next rule
25
+ const nextRuleSet = reversed.slice(ruleIndex + 1);
26
+ const nextRuleIndex = nextRuleSet.findIndex(rule => rule.isFor(node));
27
+ const defaultFn = (n = node, ctx = context, localInterator = interator) => {
28
+ if (nextRuleIndex !== -1) {
29
+ nextRuleSet[nextRuleIndex].fn(n, ctx, localInterator, () => {
30
+ /* empty default action */
31
+ });
32
+ }
33
+ else {
34
+ return;
35
+ }
36
+ };
37
+ if (typeof reversed[ruleIndex].fn !== 'function') {
38
+ console.warn('[pod6] bad fn for ' + JSON.stringify(node, null, 2));
39
+ }
40
+ return reversed[ruleIndex].fn(node, context, interator, defaultFn);
41
+ }
42
+ else {
43
+ // not found rule
44
+ const newNode = { ...node };
45
+ if (newNode.hasOwnProperty('content')) {
46
+ return interator(newNode.content, context);
47
+ }
48
+ }
49
+ }
50
+ interator.rules = rules;
51
+ return interator;
52
+ }
53
+ exports.default = thisFunc;
54
+ //# sourceMappingURL=makeInterator.js.map
@@ -0,0 +1,47 @@
1
+ import Writer from '../writer';
2
+ /**
3
+ sample | type | name
4
+ ----------------------------------
5
+ 'C<>',
6
+ 'C:fcode' fcode C
7
+ '<>' fcode any name, or /.+/
8
+ 'name' block 'name'
9
+ ':blankline' blankline any name, or /.+/
10
+ 'C:fcode' fcode C
11
+ '*:*', '*' any type any name
12
+
13
+ */
14
+ export interface RuleHandler<T = any> {
15
+ (writer: Writer, processor: any): (node: T, ctx: any, interator: any) => void;
16
+ }
17
+ export declare type RuleObject = {
18
+ [name: string]: RuleHandler;
19
+ };
20
+ export declare type Filter = {
21
+ name: string;
22
+ type?: string;
23
+ } | {
24
+ name?: any;
25
+ type: 'block' | any;
26
+ } | {};
27
+ export interface GetQuery {
28
+ (k: string): Filter;
29
+ }
30
+ export declare const makePlug: (k: string) => {};
31
+ export declare function is(query: any, node: any): boolean;
32
+ export interface Rule {
33
+ (): {};
34
+ isFor(): void;
35
+ fn(): void;
36
+ }
37
+ export declare const makeRule: (query: any, fn: any) => {
38
+ (): void;
39
+ rule: any;
40
+ isFor: (node: any) => boolean;
41
+ fn: any;
42
+ };
43
+ interface MakeRulesArray {
44
+ (key: RuleObject | Array<RuleObject>, fn?: Function): Array<any>;
45
+ }
46
+ export declare const makeRulesArray: MakeRulesArray;
47
+ export {};
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeRulesArray = exports.makeRule = exports.is = exports.makePlug = void 0;
4
+ const getQuery = function (k) {
5
+ if (k === '*:*' || k === '*') {
6
+ return {};
7
+ }
8
+ if (k === '<>') {
9
+ return { type: 'fcode' };
10
+ }
11
+ // try to split 'name:type'
12
+ let [name, type] = k.split(':');
13
+ if (name && type) {
14
+ return { name, type };
15
+ }
16
+ if (!name) {
17
+ return { type };
18
+ }
19
+ if (!type) {
20
+ // check C<>
21
+ const re = name.match(/(.+)\<\>/);
22
+ if (re) {
23
+ return { type: 'fcode', name: re[1] };
24
+ }
25
+ return { name, type: 'block' };
26
+ }
27
+ return { name, type };
28
+ };
29
+ const makePlug = (k) => {
30
+ const res = getQuery(k);
31
+ // @ts-ignores
32
+ let { name, type } = res;
33
+ if (type && type === '*') {
34
+ return { name };
35
+ }
36
+ if (name && name === '*') {
37
+ return { type };
38
+ }
39
+ return res;
40
+ };
41
+ exports.makePlug = makePlug;
42
+ // is - check if node have handler
43
+ function is(query, node) {
44
+ function isEmpty(obj) {
45
+ for (var prop in obj) {
46
+ if (obj.hasOwnProperty(prop))
47
+ return false;
48
+ }
49
+ return true;
50
+ }
51
+ // check if query empty
52
+ if (isEmpty(query))
53
+ return true;
54
+ for (var prop in query) {
55
+ if (query === undefined) {
56
+ console.warn('[pod6] undefined key!!!');
57
+ }
58
+ if (query.hasOwnProperty(prop)) {
59
+ if (node === undefined) {
60
+ console.warn('[pod6] undefined node!!!');
61
+ }
62
+ if (node && node.hasOwnProperty(prop)) {
63
+ if (query[prop] !== node[prop]) {
64
+ return false;
65
+ }
66
+ }
67
+ else {
68
+ return false;
69
+ }
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+ exports.is = is;
75
+ const makeRule = (query, fn) => {
76
+ rule.rule = query;
77
+ rule.isFor = isFor;
78
+ rule.fn = fn;
79
+ return rule;
80
+ function rule() { }
81
+ function isFor(node) {
82
+ if ('string' === typeof node)
83
+ return false;
84
+ return is(query, node);
85
+ }
86
+ };
87
+ exports.makeRule = makeRule;
88
+ const makeRulesArray = (key, fn) => {
89
+ if (key instanceof Array) {
90
+ return key.reduce((acc, item) => {
91
+ acc.push(...(0, exports.makeRulesArray)(item));
92
+ return acc;
93
+ }, []);
94
+ }
95
+ if (key instanceof Object) {
96
+ let rules = [];
97
+ for (var prop in key) {
98
+ if (key.hasOwnProperty(prop)) {
99
+ rules.push((0, exports.makeRule)((0, exports.makePlug)(prop), key[prop]));
100
+ }
101
+ }
102
+ return rules;
103
+ }
104
+ return [(0, exports.makeRule)((0, exports.makePlug)(key), fn)];
105
+ };
106
+ exports.makeRulesArray = makeRulesArray;
107
+ //# sourceMappingURL=makeQuery.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ const makePlug = require('./makeQuery').makePlug;
2
+ const fixtures = [
3
+ 'name:block',
4
+ {
5
+ name: 'name',
6
+ type: 'block',
7
+ },
8
+ 'C<>',
9
+ {
10
+ name: 'C',
11
+ type: 'fcode',
12
+ },
13
+ ':blankline',
14
+ {
15
+ type: 'blankline',
16
+ },
17
+ '*:block',
18
+ {
19
+ type: 'block',
20
+ },
21
+ '*:*',
22
+ {},
23
+ '*',
24
+ {},
25
+ '<>',
26
+ {
27
+ type: 'fcode',
28
+ },
29
+ 'name',
30
+ {
31
+ name: 'name',
32
+ type: 'block',
33
+ },
34
+ 'Special<>',
35
+ {
36
+ name: 'Special',
37
+ type: 'fcode',
38
+ },
39
+ ];
40
+ const pairs = fixtures.reduce(function (result, value, index, array) {
41
+ if (index % 2 === 0)
42
+ result.push(array.slice(index, index + 2));
43
+ return result;
44
+ }, []);
45
+ const log = a => console.log(JSON.stringify(a, null, 2));
46
+ describe('run make query helpers tests', () => {
47
+ pairs.map(([k, v], idx) => {
48
+ test(`test ${idx}`, () => expect(makePlug(k)).toEqual(v));
49
+ });
50
+ });
51
+ //# sourceMappingURL=makeQuery.test.js.map
@@ -0,0 +1,7 @@
1
+ export declare function isNamedBlock(name: any): boolean;
2
+ export declare function isSemanticBlock(node: any): boolean;
3
+ export declare const makeTransformer: (rule: any) => {
4
+ (node: any, context?: any): any;
5
+ rules: any[];
6
+ };
7
+ export default makeTransformer;