This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

10
node_modules/pug-linker/HISTORY.md generated vendored Normal file
View File

@ -0,0 +1,10 @@
1.0.1 / 2016-08-26
==================
* Update to `pug-walk@^1.0.0`
1.0.0 / 2016-06-02
==================
* Mark as stable
* Make unexpected blocks errors

19
node_modules/pug-linker/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2015 Forbes Lindesay
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

28
node_modules/pug-linker/README.md generated vendored Normal file
View File

@ -0,0 +1,28 @@
# pug-linker
Link multiple pug ASTs together using include/extends
[![Build Status](https://img.shields.io/travis/pugjs/pug-linker/master.svg)](https://travis-ci.org/pugjs/pug-linker)
[![Dependencies Status](https://david-dm.org/pugjs/pug/status.svg?path=packages/pug-linker)](https://david-dm.org/pugjs/pug?path=packages/pug-linker)
[![DevDependencies Status](https://david-dm.org/pugjs/pug/dev-status.svg?path=packages/pug-linker)](https://david-dm.org/pugjs/pug?path=packages/pug-linker&type=dev)
[![NPM version](https://img.shields.io/npm/v/pug-linker.svg)](https://www.npmjs.org/package/pug-linker)
## Installation
npm install pug-linker
## Usage
```js
var link = require('pug-linker');
```
### `link(ast)`
Flatten the Pug AST of inclusion and inheritance.
This function merely links the AST together; it doesn't read the file system to resolve and parse included and extended files. Thus, the main AST must already have the ASTs of the included and extended files embedded in the `FileReference` nodes. `pug-load` is designed to do that.
## License
MIT

185
node_modules/pug-linker/index.js generated vendored Normal file
View File

@ -0,0 +1,185 @@
'use strict';
var assert = require('assert');
var walk = require('pug-walk');
function error() {
throw require('pug-error').apply(null, arguments);
}
module.exports = link;
function link(ast) {
assert(ast.type === 'Block', 'The top level element should always be a block');
var extendsNode = null;
if (ast.nodes.length) {
var hasExtends = ast.nodes[0].type === 'Extends';
checkExtendPosition(ast, hasExtends);
if (hasExtends) {
extendsNode = ast.nodes.shift();
}
}
ast = applyIncludes(ast);
ast.declaredBlocks = findDeclaredBlocks(ast);
if (extendsNode) {
var mixins = [];
var expectedBlocks = [];
ast.nodes.forEach(function addNode(node) {
if (node.type === 'NamedBlock') {
expectedBlocks.push(node);
} else if (node.type === 'Block') {
node.nodes.forEach(addNode);
} else if (node.type === 'Mixin' && node.call === false) {
mixins.push(node);
} else {
error('UNEXPECTED_NODES_IN_EXTENDING_ROOT', 'Only named blocks and mixins can appear at the top level of an extending template', node);
}
});
var parent = link(extendsNode.file.ast);
extend(parent.declaredBlocks, ast);
var foundBlockNames = [];
walk(parent, function (node) {
if (node.type === 'NamedBlock') {
foundBlockNames.push(node.name);
}
});
expectedBlocks.forEach(function (expectedBlock) {
if (foundBlockNames.indexOf(expectedBlock.name) === -1) {
error(
'UNEXPECTED_BLOCK',
'Unexpected block ' + expectedBlock.name,
expectedBlock
);
}
});
Object.keys(ast.declaredBlocks).forEach(function (name) {
parent.declaredBlocks[name] = ast.declaredBlocks[name];
});
parent.nodes = mixins.concat(parent.nodes);
parent.hasExtends = true;
return parent;
}
return ast;
}
function findDeclaredBlocks(ast) /*: {[name: string]: Array<BlockNode>}*/ {
var definitions = {};
walk(ast, function before(node) {
if (node.type === 'NamedBlock' && node.mode === 'replace') {
definitions[node.name] = definitions[node.name] || [];
definitions[node.name].push(node);
}
});
return definitions;
}
function flattenParentBlocks(parentBlocks, accumulator) {
accumulator = accumulator || [];
parentBlocks.forEach(function (parentBlock) {
if (parentBlock.parents) {
flattenParentBlocks(parentBlock.parents, accumulator);
}
accumulator.push(parentBlock);
});
return accumulator;
}
function extend(parentBlocks, ast) {
var stack = {};
walk(ast, function before(node) {
if (node.type === 'NamedBlock') {
if (stack[node.name] === node.name) {
return node.ignore = true;
}
stack[node.name] = node.name;
var parentBlockList = parentBlocks[node.name] ? flattenParentBlocks(parentBlocks[node.name]) : [];
if (parentBlockList.length) {
node.parents = parentBlockList;
parentBlockList.forEach(function (parentBlock) {
switch (node.mode) {
case 'append':
parentBlock.nodes = parentBlock.nodes.concat(node.nodes);
break;
case 'prepend':
parentBlock.nodes = node.nodes.concat(parentBlock.nodes);
break;
case 'replace':
parentBlock.nodes = node.nodes;
break;
}
});
}
}
}, function after(node) {
if (node.type === 'NamedBlock' && !node.ignore) {
delete stack[node.name];
}
});
}
function applyIncludes(ast, child) {
return walk(ast, function before(node, replace) {
if (node.type === 'RawInclude') {
replace({type: 'Text', val: node.file.str.replace(/\r/g, '')});
}
}, function after(node, replace) {
if (node.type === 'Include') {
var childAST = link(node.file.ast);
if (childAST.hasExtends) {
childAST = removeBlocks(childAST);
}
replace(applyYield(childAST, node.block));
}
});
}
function removeBlocks(ast) {
return walk(ast, function (node, replace) {
if (node.type === 'NamedBlock') {
replace({
type: 'Block',
nodes: node.nodes
});
}
});
}
function applyYield(ast, block) {
if (!block || !block.nodes.length) return ast;
var replaced = false;
ast = walk(ast, null, function (node, replace) {
if (node.type === 'YieldBlock') {
replaced = true;
node.type = 'Block';
node.nodes = [block];
}
});
function defaultYieldLocation(node) {
var res = node;
for (var i = 0; i < node.nodes.length; i++) {
if (node.nodes[i].textOnly) continue;
if (node.nodes[i].type === 'Block') {
res = defaultYieldLocation(node.nodes[i]);
} else if (node.nodes[i].block && node.nodes[i].block.nodes.length) {
res = defaultYieldLocation(node.nodes[i].block);
}
}
return res;
}
if (!replaced) {
// todo: probably should deprecate this with a warning
defaultYieldLocation(ast).nodes.push(block);
}
return ast;
}
function checkExtendPosition(ast, hasExtends) {
var legitExtendsReached = false;
walk(ast, function (node) {
if (node.type === 'Extends') {
if (hasExtends && !legitExtendsReached) {
legitExtendsReached = true;
} else {
error('EXTENDS_NOT_FIRST', 'Declaration of template inheritance ("extends") should be the first thing in the file. There can only be one extends statement per file.', node);
}
}
});
}

57
node_modules/pug-linker/package.json generated vendored Normal file
View File

@ -0,0 +1,57 @@
{
"_args": [
[
"pug-linker@3.0.6",
"/Users/tatiana/selfdefined"
]
],
"_from": "pug-linker@3.0.6",
"_id": "pug-linker@3.0.6",
"_inBundle": false,
"_integrity": "sha512-bagfuHttfQOpANGy1Y6NJ+0mNb7dD2MswFG2ZKj22s8g0wVsojpRlqveEQHmgXXcfROB2RT6oqbPYr9EN2ZWzg==",
"_location": "/pug-linker",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "pug-linker@3.0.6",
"name": "pug-linker",
"escapedName": "pug-linker",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/pug"
],
"_resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "Forbes Lindesay"
},
"dependencies": {
"pug-error": "^1.3.3",
"pug-walk": "^1.1.8"
},
"description": "Link multiple pug ASTs together using include/extends",
"devDependencies": {
"pug-lexer": "^4.1.0",
"pug-load": "^2.0.12",
"pug-parser": "^5.0.1"
},
"files": [
"index.js"
],
"gitHead": "1bdf628a70fda7a0d840c52f3abce54b1c6b0130",
"keywords": [
"pug"
],
"license": "MIT",
"name": "pug-linker",
"repository": {
"type": "git",
"url": "https://github.com/pugjs/pug/tree/master/packages/pug-linker"
},
"version": "3.0.6"
}