<commit_before> /**
 * @author       Richard Davey <rich@photonstorm.com>
 * @copyright    2019 Photon Storm Ltd.
 * @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
 */

var CONST = require('./const');
var GetOverlapY = require('./GetOverlapY');

/**
 * Separates two overlapping bodies on the Y-axis (vertically).
 *
 * Separation involves moving two overlapping bodies so they don't overlap anymore
 * and adjusting their velocities based on their mass. This is a core part of collision detection.
 *
 * The bodies won't be separated if there is no vertical overlap between them, if they are static,
 * or if either one uses custom logic for its separation.
 *
 * @function Phaser.Physics.Arcade.SeparateY
 * @since 3.0.0
 *
 * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate. This is our priority body.
 * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate.
 * @param {boolean} overlapOnly - If `true`, the bodies will only have their overlap data set and no separation will take place.
 * @param {number} bias - A value to add to the delta value during overlap checking. Used to prevent sprite tunneling.
 *
 * @return {boolean} `true` if the two bodies overlap vertically, otherwise `false`.
 */
var SeparateY = function (body1, body2, overlapOnly, bias)
{
    var result = GetOverlapY(body1, body2, overlapOnly, bias);

    var overlap = result[0];
    var faceTop = result[1];
    var intersects = result[2];

    var velocity1 = body1.velocity;
    var velocity2 = body2.velocity;

    var blocked1 = body1.blocked;
    var blocked2 = body2.blocked;

    var body1BlockedY = (blocked1.up || blocked1.down);
    var body2BlockedY = (blocked2.up || blocked2.down);

    var body1Immovable = (body1.physicsType === CONST.STATIC_BODY || body1.immovable);
    var body2Immovable = (body2.physicsType === CONST.STATIC_BODY || body2.immovable);

    //  Can't separate two immovable bodies, or a body with its own custom separation logic
    if (!intersects || overlapOnly || (body1Immovable && body2Immovable) || body1.customSeparateY || body2.customSeparateY)
    {
        //  return true if there was some overlap, otherwise false.
        return (overlap !== 0) || (body1.embedded && body2.embedded);
    }

    if (blocked1.up && blocked1.down)
    {
        body1Immovable = true;
    }

    if (blocked2.up && blocked2.down)
    {
        body2Immovable = true;
    }

    //  Adjust their positions and velocities accordingly based on the amount of overlap
    var v1 = velocity1.y;
    var v2 = velocity2.y;

    //  At this point, the velocity from gravity, world rebounds, etc has been factored in.
    //  The body is moving the direction it wants to, but may be blocked.

    var ny1 = v1;
    var ny2 = v2;

    if (body1Immovable && body2Immovable)
    {
        //  Both bodies are equally blocked, we can't do anything with them
        console.log('Both bodies are equally blocked, kill velocity?');
        // ny1 = 0;
        // ny2 = 0;
    }
    else if (!body1Immovable && !body1BlockedY && !body2Immovable && !body2BlockedY)
    {
        //  Neither body is immovable or blocked, so they get a new velocity based on mass
        var mass1 = body1.mass;
        var mass2 = body2.mass;

        var nv1 = Math.sqrt((v2 * v2 * mass2) / mass1) * ((v2 > 0) ? 1 : -1);
        var nv2 = Math.sqrt((v1 * v1 * mass1) / mass2) * ((v1 > 0) ? 1 : -1);

        var avg = (nv1 + nv2) * 0.5;

        nv1 -= avg;
        nv2 -= avg;

        ny1 = avg + nv1 * body1.bounce.y;
        ny2 = avg + nv2 * body2.bounce.y;
    }
    else if (body1BlockedY || body1Immovable)
    {
        //  Body1 is blocked or never changes speed, so adjust body2 speed
        ny2 = v1 - v2 * body2.bounce.y;
    }
    else if (body2BlockedY || body2Immovable)
    {
        //  Body2 is blocked or never changes speed, so adjust body1 speed
        ny1 = v2 - v1 * body1.bounce.y;
    }

    //  Velocities calculated, time to work out what moves where
    if (overlap !== 0)
    {
        var share = overlap * 0.5;
        var amount1 = body1.getMoveY(share);
        var amount2 = body2.getMoveY(-share);

        if (amount1 !== share)
        {
            amount2 -= (share - amount1);
        }
        else if (amount2 !== -share)
        {
            amount1 += (share + amount2);
        }

        body1.y += amount1;
        body2.y += amount2;
    }

    if (body1BlockedY || body2BlockedY)
    {
        if (body1.deltaY() < 0 && blocked1.up && blocked1.by === body2)
        {
            // console.log('up1');

            //  Body1 is moving UP and is blocked by Body2

            if (faceTop)
            {
                //  Body1 top hit Body2 bottom and is blocked from moving up
                body1.y = body2.bottom;
            }
            else
            {
                //  Body1 bottom hit Body2 top and is blocked from moving up
                body1.bottom = body2.y;
            }

            body1.forcePosition = (body1.bounce.y === 0);

            if (ny1 < 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny1 = 0;
            }
        }
        else if (body1.deltaY() > 0 && blocked1.down && blocked1.by === body2)
        {
            // console.log('down1');

            //  Body1 is moving DOWN and is blocked by Body2

            if (faceTop)
            {
                //  Body1 top hit Body2 bottom and is blocked from moving down
                body1.y = body2.bottom;
            }
            else
            {
                //  Body1 bottom hit Body2 top and is blocked from moving down
                body1.bottom = body2.y;
            }

            body1.forcePosition = (body1.bounce.y === 0);

            if (ny1 > 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny1 = 0;
            }
        }

        if (body2.deltaY() < 0 && blocked2.up && blocked2.by === body1)
        {
            // console.log('up2');

            //  Body2 is moving UP and is blocked by Body1

            if (faceTop)
            {
                //  Body2 bottom hit Body1 top and is blocked from moving up
                body2.bottom = body1.y;
            }
            else
            {
                //  Body2 top hit Body1 bottom and is blocked from moving up
                body2.y = body1.bottom;
            }

            body2.forcePosition = (body2.bounce.y === 0);

            if (ny2 < 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny2 = 0;
            }
        }
        else if (body2.deltaY() > 0 && blocked2.down && blocked2.by === body1)
        {
            // console.log('down2');

            //  Body2 is moving DOWN and is blocked by Body1

            if (faceTop)
            {
                //  Body2 bottom hit Body1 top and is blocked from moving down
                body2.bottom = body1.y;
            }
            else
            {
                //  Body2 top hit Body1 bottom and is blocked from moving down
                body2.y = body1.bottom;
            }

            body2.forcePosition = (body2.bounce.y === 0);

            if (ny2 > 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny2 = 0;
            }
        }
    }

    //  If body was asleep, we only wake it up for significant changes in velocity
    if (body1.sleeping && Math.abs(ny1) < 10)
    {
        ny1 = 0;
    }

    if (body2.sleeping && Math.abs(ny2) < 10)
    {
        ny2 = 0;
    }

    velocity1.y = ny1;
    velocity2.y = ny2;

    //  TODO: This is special case code that handles things like horizontal moving platforms you can ride
    // if (body2.moves)
    // {
    //     body1.x += body1.getMoveX((body2.deltaX()) * body2.friction.x, true);
    // }

    //  If we got this far then there WAS overlap, and separation is complete, so return true
    return true;
};

module.exports = SeparateY;
<commit_msg>Wake-up sleeping bodies on impact<commit_after> /**
 * @author       Richard Davey <rich@photonstorm.com>
 * @copyright    2019 Photon Storm Ltd.
 * @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
 */

var CONST = require('./const');
var GetOverlapY = require('./GetOverlapY');

/**
 * Separates two overlapping bodies on the Y-axis (vertically).
 *
 * Separation involves moving two overlapping bodies so they don't overlap anymore
 * and adjusting their velocities based on their mass. This is a core part of collision detection.
 *
 * The bodies won't be separated if there is no vertical overlap between them, if they are static,
 * or if either one uses custom logic for its separation.
 *
 * @function Phaser.Physics.Arcade.SeparateY
 * @since 3.0.0
 *
 * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate. This is our priority body.
 * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate.
 * @param {boolean} overlapOnly - If `true`, the bodies will only have their overlap data set and no separation will take place.
 * @param {number} bias - A value to add to the delta value during overlap checking. Used to prevent sprite tunneling.
 *
 * @return {boolean} `true` if the two bodies overlap vertically, otherwise `false`.
 */
var SeparateY = function (body1, body2, overlapOnly, bias)
{
    var result = GetOverlapY(body1, body2, overlapOnly, bias);

    var overlap = result[0];
    var faceTop = result[1];
    var intersects = result[2];

    var velocity1 = body1.velocity;
    var velocity2 = body2.velocity;

    var blocked1 = body1.blocked;
    var blocked2 = body2.blocked;

    var body1BlockedY = (blocked1.up || blocked1.down);
    var body2BlockedY = (blocked2.up || blocked2.down);

    var body1Immovable = (body1.physicsType === CONST.STATIC_BODY || body1.immovable);
    var body2Immovable = (body2.physicsType === CONST.STATIC_BODY || body2.immovable);

    //  Can't separate two immovable bodies, or a body with its own custom separation logic
    if (!intersects || overlapOnly || (body1Immovable && body2Immovable) || body1.customSeparateY || body2.customSeparateY)
    {
        //  return true if there was some overlap, otherwise false.
        return (overlap !== 0) || (body1.embedded && body2.embedded);
    }

    if (blocked1.up && blocked1.down)
    {
        body1Immovable = true;
    }

    if (blocked2.up && blocked2.down)
    {
        body2Immovable = true;
    }

    //  Adjust their positions and velocities accordingly based on the amount of overlap
    var v1 = velocity1.y;
    var v2 = velocity2.y;

    //  At this point, the velocity from gravity, world rebounds, etc has been factored in.
    //  The body is moving the direction it wants to, but may be blocked.

    var ny1 = v1;
    var ny2 = v2;

    if (body1Immovable && body2Immovable)
    {
        //  Both bodies are equally blocked, we can't do anything with them
        console.log('Both bodies are equally blocked, kill velocity?');
        // ny1 = 0;
        // ny2 = 0;
    }
    else if (!body1Immovable && !body1BlockedY && !body2Immovable && !body2BlockedY)
    {
        //  Neither body is immovable or blocked, so they get a new velocity based on mass
        var mass1 = body1.mass;
        var mass2 = body2.mass;

        var nv1 = Math.sqrt((v2 * v2 * mass2) / mass1) * ((v2 > 0) ? 1 : -1);
        var nv2 = Math.sqrt((v1 * v1 * mass1) / mass2) * ((v1 > 0) ? 1 : -1);

        var avg = (nv1 + nv2) * 0.5;

        nv1 -= avg;
        nv2 -= avg;

        ny1 = avg + nv1 * body1.bounce.y;
        ny2 = avg + nv2 * body2.bounce.y;
    }
    else if (body1BlockedY || body1Immovable)
    {
        //  Body1 is blocked or never changes speed, so adjust body2 speed
        ny2 = v1 - v2 * body2.bounce.y;
    }
    else if (body2BlockedY || body2Immovable)
    {
        //  Body2 is blocked or never changes speed, so adjust body1 speed
        ny1 = v2 - v1 * body1.bounce.y;
    }

    //  Velocities calculated, time to work out what moves where
    if (overlap !== 0)
    {
        var share = overlap * 0.5;
        var amount1 = body1.getMoveY(share);
        var amount2 = body2.getMoveY(-share);

        if (amount1 !== share)
        {
            amount2 -= (share - amount1);
        }
        else if (amount2 !== -share)
        {
            amount1 += (share + amount2);
        }

        body1.y += amount1;
        body2.y += amount2;

        if (amount1)
        {
            body1.wake();
        }

        if (amount2)
        {
            body2.wake();
        }
    }

    if (body1BlockedY || body2BlockedY)
    {
        if (body1.deltaY() < 0 && blocked1.up && blocked1.by === body2)
        {
            // console.log('up1');

            //  Body1 is moving UP and is blocked by Body2

            if (faceTop)
            {
                //  Body1 top hit Body2 bottom and is blocked from moving up
                body1.y = body2.bottom;
            }
            else
            {
                //  Body1 bottom hit Body2 top and is blocked from moving up
                body1.bottom = body2.y;
            }

            body1.forcePosition = (body1.bounce.y === 0);

            if (ny1 < 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny1 = 0;
            }
        }
        else if (body1.deltaY() > 0 && blocked1.down && blocked1.by === body2)
        {
            // console.log('down1');

            //  Body1 is moving DOWN and is blocked by Body2

            if (faceTop)
            {
                //  Body1 top hit Body2 bottom and is blocked from moving down
                body1.y = body2.bottom;
            }
            else
            {
                //  Body1 bottom hit Body2 top and is blocked from moving down
                body1.bottom = body2.y;
            }

            body1.forcePosition = (body1.bounce.y === 0);

            if (ny1 > 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny1 = 0;
            }
        }

        if (body2.deltaY() < 0 && blocked2.up && blocked2.by === body1)
        {
            // console.log('up2');

            //  Body2 is moving UP and is blocked by Body1

            if (faceTop)
            {
                //  Body2 bottom hit Body1 top and is blocked from moving up
                body2.bottom = body1.y;
            }
            else
            {
                //  Body2 top hit Body1 bottom and is blocked from moving up
                body2.y = body1.bottom;
            }

            body2.forcePosition = (body2.bounce.y === 0);

            if (ny2 < 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny2 = 0;
            }
        }
        else if (body2.deltaY() > 0 && blocked2.down && blocked2.by === body1)
        {
            // console.log('down2');

            //  Body2 is moving DOWN and is blocked by Body1

            if (faceTop)
            {
                //  Body2 bottom hit Body1 top and is blocked from moving down
                body2.bottom = body1.y;
            }
            else
            {
                //  Body2 top hit Body1 bottom and is blocked from moving down
                body2.y = body1.bottom;
            }

            body2.forcePosition = (body2.bounce.y === 0);

            if (ny2 > 0)
            {
                //  Velocity hasn't been reversed, so cancel it
                ny2 = 0;
            }
        }
    }

    //  If body was asleep, we only wake it up for significant changes in velocity
    if (body1.sleeping && Math.abs(ny1) < 10)
    {
        ny1 = 0;
    }

    if (body2.sleeping && Math.abs(ny2) < 10)
    {
        ny2 = 0;
    }

    velocity1.y = ny1;
    velocity2.y = ny2;

    //  TODO: This is special case code that handles things like horizontal moving platforms you can ride
    // if (body2.moves)
    // {
    //     body1.x += body1.getMoveX((body2.deltaX()) * body2.friction.x, true);
    // }

    //  If we got this far then there WAS overlap, and separation is complete, so return true
    return true;
};

module.exports = SeparateY;
<|endoftext|>


<commit_before>var graphConfig = new GitGraph.Template({
    branch: {
        color: "#000000",
        lineWidth: 3,
        spacingX: 60,
        mergeStyle: "straight",
        showLabel: true,                // display branch names on graph
        labelFont: "normal 10pt Arial"
    },
    commit: {
        spacingY: -30,
        dot: {
            size: 8,
            strokeColor: "#000000",
            strokeWidth: 4
        },
        tag: {
            font: "normal 10pt Arial",
            color: "yellow"
        },
        message: {
            color: "black",
            font: "normal 12pt Arial",
            displayAuthor: false,
            displayBranch: false,
            displayHash: false,
        }
    },
    arrow: {
        size: 8,
        offset: 3
    }
});

var config = {
  template: graphConfig,
  mode: "extended",
  orientation: "vertical"
};

var bugfixCommit = {
  messageAuthorDisplay:false,
  messageBranchDisplay:false,
  messageHashDisplay:false,
  message:"Bug fix commit(s)"
};

var stablizationCommit = {
  messageAuthorDisplay:false,
  messageBranchDisplay:false,
  messageHashDisplay:false,
  message:"Release stablization commit(s)"
};

// You can manually fix columns to control the display.
var featureCol = 0;
var developCol = 1;
var releaseCol = 2;
var supportCol = 3;
var masterCol = 4;

var gitgraph = new GitGraph(config);

var master = gitgraph.branch({name:"master", column:masterCol});
var develop = gitgraph.branch({parentBranch:master, name: "develop", column:developCol});
master.commit({messageDisplay:false}).merge(develop, {messageDisplay:false});
develop.commit({messageDisplay:false});

var feature1 = gitgraph.branch({parentBranch:develop, name:"feature/1", column:featureCol});
feature1.commit("A feature to go into v1.0.0").commit({messageDisplay:false});
feature1.merge(develop);

var feature2 = gitgraph.branch({parentBranch:develop, name:"feature/2", column:featureCol});
feature2.commit("Another feature to go into v1.0.0").commit({messageDisplay:false});
feature2.merge(develop);

var release_100 = gitgraph.branch({parentBranch: develop, name: "release/v1.0.0", column:releaseCol});
release_100.commit({message:"Start v1.0.0-rc Release Candidate builds",tag:"v1.0.0-rc",tagColor:'gray'});
develop.commit({messageDisplay:false});
release_100.commit(stablizationCommit);
release_100.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.0.0 tagged",tag:"v1.0.0"});

var support_10x = gitgraph.branch({parentBranch: master, name: "support/v1.0.x", column:supportCol});
support_10x.commit({message:"Start v1.0.1-rc Release Candidate builds",tag:"v1.0.1-rc",tagColor:'gray'}).commit(bugfixCommit);

var feature3 = gitgraph.branch({parentBranch:develop, name:"feature/3", column:featureCol});
develop.commit({messageDisplay:false});
feature3.commit("A feature to go into v1.1.0").commit({messageDisplay:false});
feature3.merge(develop);

support_10x.commit({dotStrokeWidth: 10, message: "Release v1.0.1 tagged",tag:"v1.0.1"}).merge(develop);

develop.commit({messageDisplay:false});
support_10x.commit({message:"Start v1.0.2-rc Release Candidate builds",tag:"v1.0.2-rc",tagColor:'gray'})
support_10x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.0.2 tagged",tag:'v1.0.2'});
support_10x.merge(develop);
develop.commit({messageDisplay:false});

var release_110 = gitgraph.branch({parentBranch: develop, name: "release/v1.1.0", column:releaseCol});
release_110.commit({message:"Start v1.1.0-rc Release Candidate builds",tag:"v1.1.0-rc",tagColor:'gray'})
release_110.commit(stablizationCommit);
release_110.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.1.0 tagged",tag:"v1.1.0"});

var support_11x = gitgraph.branch({parentBranch: master, name: "support/v1.1.x", column:supportCol});
support_11x.commit({message:"Start v1.1.1-rc Release Candidate builds",tag:"v1.1.1-rc",tagColor:'gray'})
support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.1 tagged",tag:"v1.1.1"});
support_11x.merge(develop);
develop.commit({messageDisplay:false});

var feature4 = gitgraph.branch({parentBranch:develop, name:"feature/4", column:featureCol});
develop.commit({messageDisplay:false});
feature4.commit("A feature to go into v1.2.0").commit({messageDisplay:false});
feature4.merge(develop);

support_11x.commit({message:"Start v1.1.2-rc Release Candidate builds",tag:"v1.1.2-rc",tagColor:'gray'})
support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.2",tag:"v1.1.2"});
support_11x.merge(develop);
develop.commit({messageDisplay:false});

var feature5 = gitgraph.branch({parentBranch:develop, name:"feature/5", column:featureCol});
develop.commit({messageDisplay:false});
feature5.commit("Another feature to go into v1.2.0").commit({messageDisplay:false});
feature5.merge(develop);

support_11x.commit({message:"Start v1.1.3-rc Release Candidate builds",tag:"v1.1.3-rc",tagColor:'gray'})
support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.3 tagged",tag:"v1.1.3"});
support_11x.merge(develop);
develop.commit({messageDisplay:false});

var release_120 = gitgraph.branch({parentBranch: develop, name: "release/v1.2.0", column:releaseCol});
release_120.commit({message:"Start v1.2.0-rc Release Candidate builds",tag:"v1.2.0-rc",tagColor:'gray'})
release_120.commit(stablizationCommit);
release_120.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.2.0 tagged",tag:"v1.2.0"});
develop.commit({messageDisplay:false});
<commit_msg>Add initial commit to gitflow support example<commit_after>var graphConfig = new GitGraph.Template({
    branch: {
        color: "#000000",
        lineWidth: 3,
        spacingX: 60,
        mergeStyle: "straight",
        showLabel: true,                // display branch names on graph
        labelFont: "normal 10pt Arial"
    },
    commit: {
        spacingY: -30,
        dot: {
            size: 8,
            strokeColor: "#000000",
            strokeWidth: 4
        },
        tag: {
            font: "normal 10pt Arial",
            color: "yellow"
        },
        message: {
            color: "black",
            font: "normal 12pt Arial",
            displayAuthor: false,
            displayBranch: false,
            displayHash: false,
        }
    },
    arrow: {
        size: 8,
        offset: 3
    }
});

var config = {
  template: graphConfig,
  mode: "extended",
  orientation: "vertical"
};

var bugfixCommit = {
  messageAuthorDisplay:false,
  messageBranchDisplay:false,
  messageHashDisplay:false,
  message:"Bug fix commit(s)"
};

var stablizationCommit = {
  messageAuthorDisplay:false,
  messageBranchDisplay:false,
  messageHashDisplay:false,
  message:"Release stablization commit(s)"
};

// You can manually fix columns to control the display.
var featureCol = 0;
var developCol = 1;
var releaseCol = 2;
var supportCol = 3;
var masterCol = 4;

var gitgraph = new GitGraph(config);

var master = gitgraph.branch({name:"master", column:masterCol});
master.commit("Initial commit");

var develop = gitgraph.branch({parentBranch:master, name: "develop", column:developCol});
master.commit({messageDisplay:false}).merge(develop, {messageDisplay:false});
develop.commit({messageDisplay:false});

var feature1 = gitgraph.branch({parentBranch:develop, name:"feature/1", column:featureCol});
feature1.commit("A feature to go into v1.0.0").commit({messageDisplay:false});
feature1.merge(develop);

var feature2 = gitgraph.branch({parentBranch:develop, name:"feature/2", column:featureCol});
feature2.commit("Another feature to go into v1.0.0").commit({messageDisplay:false});
feature2.merge(develop);

var release_100 = gitgraph.branch({parentBranch: develop, name: "release/v1.0.0", column:releaseCol});
release_100.commit({message:"Start v1.0.0-rc Release Candidate builds",tag:"v1.0.0-rc",tagColor:'gray'});
develop.commit({messageDisplay:false});
release_100.commit(stablizationCommit);
release_100.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.0.0 tagged",tag:"v1.0.0"});

var support_10x = gitgraph.branch({parentBranch: master, name: "support/v1.0.x", column:supportCol});
support_10x.commit({message:"Start v1.0.1-rc Release Candidate builds",tag:"v1.0.1-rc",tagColor:'gray'}).commit(bugfixCommit);

var feature3 = gitgraph.branch({parentBranch:develop, name:"feature/3", column:featureCol});
develop.commit({messageDisplay:false});
feature3.commit("A feature to go into v1.1.0").commit({messageDisplay:false});
feature3.merge(develop);

support_10x.commit({dotStrokeWidth: 10, message: "Release v1.0.1 tagged",tag:"v1.0.1"}).merge(develop);

develop.commit({messageDisplay:false});
support_10x.commit({message:"Start v1.0.2-rc Release Candidate builds",tag:"v1.0.2-rc",tagColor:'gray'})
support_10x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.0.2 tagged",tag:'v1.0.2'});
support_10x.merge(develop);
develop.commit({messageDisplay:false});

var release_110 = gitgraph.branch({parentBranch: develop, name: "release/v1.1.0", column:releaseCol});
release_110.commit({message:"Start v1.1.0-rc Release Candidate builds",tag:"v1.1.0-rc",tagColor:'gray'})
release_110.commit(stablizationCommit);
release_110.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.1.0 tagged",tag:"v1.1.0"});

var support_11x = gitgraph.branch({parentBranch: master, name: "support/v1.1.x", column:supportCol});
support_11x.commit({message:"Start v1.1.1-rc Release Candidate builds",tag:"v1.1.1-rc",tagColor:'gray'})
support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.1 tagged",tag:"v1.1.1"});
support_11x.merge(develop);
develop.commit({messageDisplay:false});

var feature4 = gitgraph.branch({parentBranch:develop, name:"feature/4", column:featureCol});
develop.commit({messageDisplay:false});
feature4.commit("A feature to go into v1.2.0").commit({messageDisplay:false});
feature4.merge(develop);

support_11x.commit({message:"Start v1.1.2-rc Release Candidate builds",tag:"v1.1.2-rc",tagColor:'gray'})
support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.2",tag:"v1.1.2"});
support_11x.merge(develop);
develop.commit({messageDisplay:false});

var feature5 = gitgraph.branch({parentBranch:develop, name:"feature/5", column:featureCol});
develop.commit({messageDisplay:false});
feature5.commit("Another feature to go into v1.2.0").commit({messageDisplay:false});
feature5.merge(develop);

support_11x.commit({message:"Start v1.1.3-rc Release Candidate builds",tag:"v1.1.3-rc",tagColor:'gray'})
support_11x.commit(bugfixCommit).commit({dotStrokeWidth: 10, message: "Release v1.1.3 tagged",tag:"v1.1.3"});
support_11x.merge(develop);
develop.commit({messageDisplay:false});

var release_120 = gitgraph.branch({parentBranch: develop, name: "release/v1.2.0", column:releaseCol});
release_120.commit({message:"Start v1.2.0-rc Release Candidate builds",tag:"v1.2.0-rc",tagColor:'gray'})
release_120.commit(stablizationCommit);
release_120.merge(develop).merge(master, {dotStrokeWidth: 10, message: "Release v1.2.0 tagged",tag:"v1.2.0"});
develop.commit({messageDisplay:false});
<|endoftext|>


<commit_before>define([
        '../Core/BoundingRectangle',
        '../Core/Color',
        '../Core/defined',
        '../Core/destroyObject',
        '../Core/PixelFormat',
        '../Renderer/ClearCommand',
        '../Renderer/Framebuffer',
        '../Renderer/PixelDatatype',
        '../Renderer/RenderState',
        '../Renderer/ShaderSource',
        '../Renderer/Sampler',
        '../Renderer/Texture',
        '../Renderer/TextureWrap',
        '../Renderer/TextureMagnificationFilter',
        '../Renderer/TextureMinificationFilter',
        '../Shaders/PostProcessStages/DepthViewPacked',
        '../Shaders/PostProcessStages/PassThrough',
        '../Shaders/PostProcessStages/PassThroughDepth'
    ], function(
        BoundingRectangle,
        Color,
        defined,
        destroyObject,
        PixelFormat,
        ClearCommand,
        Framebuffer,
        PixelDatatype,
        RenderState,
        ShaderSource,
        Sampler,
        Texture,
        TextureWrap,
        TextureMagnificationFilter,
        TextureMinificationFilter,
        DepthViewPacked,
        PassThrough,
        PassThroughDepth) {
    'use strict';

    /**
     * @private
     */
    function GlobeDepth() {
        this._colorTexture = undefined;
        this._depthStencilTexture = undefined;
        this._globeDepthTexture = undefined;

        this.framebuffer = undefined;
        this._copyDepthFramebuffer = undefined;

        this._clearColorCommand = undefined;
        this._copyColorCommand = undefined;
        this._copyDepthCommand = undefined;

        this._viewport = new BoundingRectangle();
        this._rs = undefined;

        this._useScissorTest = false;
        this._scissorRectangle = undefined;

        this._useLogDepth = undefined;

        this._debugGlobeDepthViewportCommand = undefined;
    }

    function executeDebugGlobeDepth(globeDepth, context, passState, useLogDepth) {
        if (!defined(globeDepth._debugGlobeDepthViewportCommand) || useLogDepth !== globeDepth._useLogDepth) {
            var fsSource =
                'uniform sampler2D u_depthTexture;\n' +
                'varying vec2 v_textureCoordinates;\n' +
                'void main()\n' +
                '{\n' +
                '    float z_window = czm_unpackDepth(texture2D(u_depthTexture, v_textureCoordinates));\n' +
                '    z_window = czm_reverseLogDepth(z_window); \n' +
                '    float n_range = czm_depthRange.near;\n' +
                '    float f_range = czm_depthRange.far;\n' +
                '    float z_ndc = (2.0 * z_window - n_range - f_range) / (f_range - n_range);\n' +
                '    float scale = pow(z_ndc * 0.5 + 0.5, 8.0);\n' +
                '    gl_FragColor = vec4(mix(vec3(0.0), vec3(1.0), scale), 1.0);\n' +
                '}\n';
            var fs = new ShaderSource({
                defines : [useLogDepth ? 'LOG_DEPTH' : ''],
                sources : [fsSource]
            });

            globeDepth._debugGlobeDepthViewportCommand = context.createViewportQuadCommand(fs, {
                uniformMap : {
                    u_depthTexture : function() {
                        return globeDepth._globeDepthTexture;
                    }
                },
                owner : globeDepth
            });

            globeDepth._useLogDepth = useLogDepth;
        }

        globeDepth._debugGlobeDepthViewportCommand.execute(context, passState);
    }

    function destroyTextures(globeDepth) {
        globeDepth._colorTexture = globeDepth._colorTexture && !globeDepth._colorTexture.isDestroyed() && globeDepth._colorTexture.destroy();
        globeDepth._depthStencilTexture = globeDepth._depthStencilTexture && !globeDepth._depthStencilTexture.isDestroyed() && globeDepth._depthStencilTexture.destroy();
        globeDepth._globeDepthTexture = globeDepth._globeDepthTexture && !globeDepth._globeDepthTexture.isDestroyed() && globeDepth._globeDepthTexture.destroy();
    }

    function destroyFramebuffers(globeDepth) {
        globeDepth.framebuffer = globeDepth.framebuffer && !globeDepth.framebuffer.isDestroyed() && globeDepth.framebuffer.destroy();
        globeDepth._copyDepthFramebuffer = globeDepth._copyDepthFramebuffer && !globeDepth._copyDepthFramebuffer.isDestroyed() && globeDepth._copyDepthFramebuffer.destroy();
    }

    function createTextures(globeDepth, context, width, height) {
        globeDepth._colorTexture = new Texture({
            context : context,
            width : width,
            height : height,
            pixelFormat : PixelFormat.RGBA,
            pixelDatatype : PixelDatatype.UNSIGNED_BYTE,
            sampler : new Sampler({
                wrapS : TextureWrap.CLAMP_TO_EDGE,
                wrapT : TextureWrap.CLAMP_TO_EDGE,
                minificationFilter : TextureMinificationFilter.NEAREST,
                magnificationFilter : TextureMagnificationFilter.NEAREST
            })
        });

        globeDepth._depthStencilTexture = new Texture({
            context : context,
            width : width,
            height : height,
            pixelFormat : PixelFormat.DEPTH_STENCIL,
            pixelDatatype : PixelDatatype.UNSIGNED_INT_24_8
        });

        globeDepth._globeDepthTexture = new Texture({
            context : context,
            width : width,
            height : height,
            pixelFormat : PixelFormat.RGBA,
            pixelDatatype : PixelDatatype.UNSIGNED_BYTE
        });
    }

    function createFramebuffers(globeDepth, context) {
        globeDepth.framebuffer = new Framebuffer({
            context : context,
            colorTextures : [globeDepth._colorTexture],
            depthStencilTexture : globeDepth._depthStencilTexture,
            destroyAttachments : false
        });

        globeDepth._copyDepthFramebuffer = new Framebuffer({
            context : context,
            colorTextures : [globeDepth._globeDepthTexture],
            destroyAttachments : false
        });
    }

    function updateFramebuffers(globeDepth, context, width, height) {
        var colorTexture = globeDepth._colorTexture;
        var textureChanged = !defined(colorTexture) || colorTexture.width !== width || colorTexture.height !== height;
        if (!defined(globeDepth.framebuffer) || textureChanged) {
            destroyTextures(globeDepth);
            destroyFramebuffers(globeDepth);
            createTextures(globeDepth, context, width, height);
            createFramebuffers(globeDepth, context);
        }
    }

    function updateCopyCommands(globeDepth, context, width, height, passState) {
        globeDepth._viewport.width = width;
        globeDepth._viewport.height = height;

        var useScissorTest = !BoundingRectangle.equals(globeDepth._viewport, passState.viewport);
        var updateScissor = useScissorTest !== globeDepth._useScissorTest;
        globeDepth._useScissorTest = useScissorTest;

        if (!BoundingRectangle.equals(globeDepth._scissorRectangle, passState.viewport)) {
            globeDepth._scissorRectangle = BoundingRectangle.clone(passState.viewport, globeDepth._scissorRectangle);
            updateScissor = true;
        }

        if (!defined(globeDepth._rs) || !BoundingRectangle.equals(globeDepth._viewport, globeDepth._rs.viewport) || updateScissor) {
            globeDepth._rs = RenderState.fromCache({
                viewport : globeDepth._viewport,
                scissorTest : {
                    enabled : globeDepth._useScissorTest,
                    rectangle : globeDepth._scissorRectangle
                }
            });
        }

        if (!defined(globeDepth._copyDepthCommand)) {
            globeDepth._copyDepthCommand = context.createViewportQuadCommand(PassThroughDepth, {
                uniformMap : {
                    u_depthTexture : function() {
                        return globeDepth._depthStencilTexture;
                    }
                },
                owner : globeDepth
            });
        }

        globeDepth._copyDepthCommand.framebuffer = globeDepth._copyDepthFramebuffer;

        if (!defined(globeDepth._copyColorCommand)) {
            globeDepth._copyColorCommand = context.createViewportQuadCommand(PassThrough, {
                uniformMap : {
                    colorTexture : function() {
                        return globeDepth._colorTexture;
                    }
                },
                owner : globeDepth
            });
        }

        globeDepth._copyDepthCommand.renderState = globeDepth._rs;
        globeDepth._copyColorCommand.renderState = globeDepth._rs;

        if (!defined(globeDepth._clearColorCommand)) {
            globeDepth._clearColorCommand = new ClearCommand({
                color : new Color(0.0, 0.0, 0.0, 0.0),
                stencil : 0.0,
                owner : globeDepth
            });
        }

        globeDepth._clearColorCommand.framebuffer = globeDepth.framebuffer;
    }

    GlobeDepth.prototype.executeDebugGlobeDepth = function(context, passState, useLogDepth) {
        executeDebugGlobeDepth(this, context, passState, useLogDepth);
    };

    GlobeDepth.prototype.update = function(context, passState) {
        var width = context.drawingBufferWidth;
        var height = context.drawingBufferHeight;

        updateFramebuffers(this, context, width, height);
        updateCopyCommands(this, context, width, height, passState);
        context.uniformState.globeDepthTexture = undefined;
    };

    GlobeDepth.prototype.executeCopyDepth = function(context, passState) {
        if (defined(this._copyDepthCommand)) {
            this._copyDepthCommand.execute(context, passState);
            context.uniformState.globeDepthTexture = this._globeDepthTexture;
        }
    };

    GlobeDepth.prototype.executeCopyColor = function(context, passState) {
        if (defined(this._copyColorCommand)) {
            this._copyColorCommand.execute(context, passState);
        }
    };

    GlobeDepth.prototype.clear = function(context, passState, clearColor) {
        var clear = this._clearColorCommand;
        if (defined(clear)) {
            Color.clone(clearColor, clear.color);
            clear.execute(context, passState);
        }
    };

    GlobeDepth.prototype.isDestroyed = function() {
        return false;
    };

    GlobeDepth.prototype.destroy = function() {
        destroyTextures(this);
        destroyFramebuffers(this);

        if (defined(this._copyColorCommand)) {
            this._copyColorCommand.shaderProgram = this._copyColorCommand.shaderProgram.destroy();
        }

        if (defined(this._copyDepthCommand)) {
            this._copyDepthCommand.shaderProgram = this._copyDepthCommand.shaderProgram.destroy();
        }

        var command = this._debugGlobeDepthViewportCommand;
        if (defined(command)) {
            command.shaderProgram = command.shaderProgram.destroy();
        }

        return destroyObject(this);
    };

    return GlobeDepth;
});
<commit_msg>Use nearest sampling for the globe depth texture.<commit_after>define([
        '../Core/BoundingRectangle',
        '../Core/Color',
        '../Core/defined',
        '../Core/destroyObject',
        '../Core/PixelFormat',
        '../Renderer/ClearCommand',
        '../Renderer/Framebuffer',
        '../Renderer/PixelDatatype',
        '../Renderer/RenderState',
        '../Renderer/ShaderSource',
        '../Renderer/Sampler',
        '../Renderer/Texture',
        '../Renderer/TextureWrap',
        '../Renderer/TextureMagnificationFilter',
        '../Renderer/TextureMinificationFilter',
        '../Shaders/PostProcessStages/DepthViewPacked',
        '../Shaders/PostProcessStages/PassThrough',
        '../Shaders/PostProcessStages/PassThroughDepth'
    ], function(
        BoundingRectangle,
        Color,
        defined,
        destroyObject,
        PixelFormat,
        ClearCommand,
        Framebuffer,
        PixelDatatype,
        RenderState,
        ShaderSource,
        Sampler,
        Texture,
        TextureWrap,
        TextureMagnificationFilter,
        TextureMinificationFilter,
        DepthViewPacked,
        PassThrough,
        PassThroughDepth) {
    'use strict';

    /**
     * @private
     */
    function GlobeDepth() {
        this._colorTexture = undefined;
        this._depthStencilTexture = undefined;
        this._globeDepthTexture = undefined;

        this.framebuffer = undefined;
        this._copyDepthFramebuffer = undefined;

        this._clearColorCommand = undefined;
        this._copyColorCommand = undefined;
        this._copyDepthCommand = undefined;

        this._viewport = new BoundingRectangle();
        this._rs = undefined;

        this._useScissorTest = false;
        this._scissorRectangle = undefined;

        this._useLogDepth = undefined;

        this._debugGlobeDepthViewportCommand = undefined;
    }

    function executeDebugGlobeDepth(globeDepth, context, passState, useLogDepth) {
        if (!defined(globeDepth._debugGlobeDepthViewportCommand) || useLogDepth !== globeDepth._useLogDepth) {
            var fsSource =
                'uniform sampler2D u_depthTexture;\n' +
                'varying vec2 v_textureCoordinates;\n' +
                'void main()\n' +
                '{\n' +
                '    float z_window = czm_unpackDepth(texture2D(u_depthTexture, v_textureCoordinates));\n' +
                '    z_window = czm_reverseLogDepth(z_window); \n' +
                '    float n_range = czm_depthRange.near;\n' +
                '    float f_range = czm_depthRange.far;\n' +
                '    float z_ndc = (2.0 * z_window - n_range - f_range) / (f_range - n_range);\n' +
                '    float scale = pow(z_ndc * 0.5 + 0.5, 8.0);\n' +
                '    gl_FragColor = vec4(mix(vec3(0.0), vec3(1.0), scale), 1.0);\n' +
                '}\n';
            var fs = new ShaderSource({
                defines : [useLogDepth ? 'LOG_DEPTH' : ''],
                sources : [fsSource]
            });

            globeDepth._debugGlobeDepthViewportCommand = context.createViewportQuadCommand(fs, {
                uniformMap : {
                    u_depthTexture : function() {
                        return globeDepth._globeDepthTexture;
                    }
                },
                owner : globeDepth
            });

            globeDepth._useLogDepth = useLogDepth;
        }

        globeDepth._debugGlobeDepthViewportCommand.execute(context, passState);
    }

    function destroyTextures(globeDepth) {
        globeDepth._colorTexture = globeDepth._colorTexture && !globeDepth._colorTexture.isDestroyed() && globeDepth._colorTexture.destroy();
        globeDepth._depthStencilTexture = globeDepth._depthStencilTexture && !globeDepth._depthStencilTexture.isDestroyed() && globeDepth._depthStencilTexture.destroy();
        globeDepth._globeDepthTexture = globeDepth._globeDepthTexture && !globeDepth._globeDepthTexture.isDestroyed() && globeDepth._globeDepthTexture.destroy();
    }

    function destroyFramebuffers(globeDepth) {
        globeDepth.framebuffer = globeDepth.framebuffer && !globeDepth.framebuffer.isDestroyed() && globeDepth.framebuffer.destroy();
        globeDepth._copyDepthFramebuffer = globeDepth._copyDepthFramebuffer && !globeDepth._copyDepthFramebuffer.isDestroyed() && globeDepth._copyDepthFramebuffer.destroy();
    }

    function createTextures(globeDepth, context, width, height) {
        globeDepth._colorTexture = new Texture({
            context : context,
            width : width,
            height : height,
            pixelFormat : PixelFormat.RGBA,
            pixelDatatype : PixelDatatype.UNSIGNED_BYTE,
            sampler : new Sampler({
                wrapS : TextureWrap.CLAMP_TO_EDGE,
                wrapT : TextureWrap.CLAMP_TO_EDGE,
                minificationFilter : TextureMinificationFilter.NEAREST,
                magnificationFilter : TextureMagnificationFilter.NEAREST
            })
        });

        globeDepth._depthStencilTexture = new Texture({
            context : context,
            width : width,
            height : height,
            pixelFormat : PixelFormat.DEPTH_STENCIL,
            pixelDatatype : PixelDatatype.UNSIGNED_INT_24_8
        });

        globeDepth._globeDepthTexture = new Texture({
            context : context,
            width : width,
            height : height,
            pixelFormat : PixelFormat.RGBA,
            pixelDatatype : PixelDatatype.UNSIGNED_BYTE,
            sampler : new Sampler({
                wrapS : TextureWrap.CLAMP_TO_EDGE,
                wrapT : TextureWrap.CLAMP_TO_EDGE,
                minificationFilter : TextureMinificationFilter.NEAREST,
                magnificationFilter : TextureMagnificationFilter.NEAREST
            })
        });
    }

    function createFramebuffers(globeDepth, context) {
        globeDepth.framebuffer = new Framebuffer({
            context : context,
            colorTextures : [globeDepth._colorTexture],
            depthStencilTexture : globeDepth._depthStencilTexture,
            destroyAttachments : false
        });

        globeDepth._copyDepthFramebuffer = new Framebuffer({
            context : context,
            colorTextures : [globeDepth._globeDepthTexture],
            destroyAttachments : false
        });
    }

    function updateFramebuffers(globeDepth, context, width, height) {
        var colorTexture = globeDepth._colorTexture;
        var textureChanged = !defined(colorTexture) || colorTexture.width !== width || colorTexture.height !== height;
        if (!defined(globeDepth.framebuffer) || textureChanged) {
            destroyTextures(globeDepth);
            destroyFramebuffers(globeDepth);
            createTextures(globeDepth, context, width, height);
            createFramebuffers(globeDepth, context);
        }
    }

    function updateCopyCommands(globeDepth, context, width, height, passState) {
        globeDepth._viewport.width = width;
        globeDepth._viewport.height = height;

        var useScissorTest = !BoundingRectangle.equals(globeDepth._viewport, passState.viewport);
        var updateScissor = useScissorTest !== globeDepth._useScissorTest;
        globeDepth._useScissorTest = useScissorTest;

        if (!BoundingRectangle.equals(globeDepth._scissorRectangle, passState.viewport)) {
            globeDepth._scissorRectangle = BoundingRectangle.clone(passState.viewport, globeDepth._scissorRectangle);
            updateScissor = true;
        }

        if (!defined(globeDepth._rs) || !BoundingRectangle.equals(globeDepth._viewport, globeDepth._rs.viewport) || updateScissor) {
            globeDepth._rs = RenderState.fromCache({
                viewport : globeDepth._viewport,
                scissorTest : {
                    enabled : globeDepth._useScissorTest,
                    rectangle : globeDepth._scissorRectangle
                }
            });
        }

        if (!defined(globeDepth._copyDepthCommand)) {
            globeDepth._copyDepthCommand = context.createViewportQuadCommand(PassThroughDepth, {
                uniformMap : {
                    u_depthTexture : function() {
                        return globeDepth._depthStencilTexture;
                    }
                },
                owner : globeDepth
            });
        }

        globeDepth._copyDepthCommand.framebuffer = globeDepth._copyDepthFramebuffer;

        if (!defined(globeDepth._copyColorCommand)) {
            globeDepth._copyColorCommand = context.createViewportQuadCommand(PassThrough, {
                uniformMap : {
                    colorTexture : function() {
                        return globeDepth._colorTexture;
                    }
                },
                owner : globeDepth
            });
        }

        globeDepth._copyDepthCommand.renderState = globeDepth._rs;
        globeDepth._copyColorCommand.renderState = globeDepth._rs;

        if (!defined(globeDepth._clearColorCommand)) {
            globeDepth._clearColorCommand = new ClearCommand({
                color : new Color(0.0, 0.0, 0.0, 0.0),
                stencil : 0.0,
                owner : globeDepth
            });
        }

        globeDepth._clearColorCommand.framebuffer = globeDepth.framebuffer;
    }

    GlobeDepth.prototype.executeDebugGlobeDepth = function(context, passState, useLogDepth) {
        executeDebugGlobeDepth(this, context, passState, useLogDepth);
    };

    GlobeDepth.prototype.update = function(context, passState) {
        var width = context.drawingBufferWidth;
        var height = context.drawingBufferHeight;

        updateFramebuffers(this, context, width, height);
        updateCopyCommands(this, context, width, height, passState);
        context.uniformState.globeDepthTexture = undefined;
    };

    GlobeDepth.prototype.executeCopyDepth = function(context, passState) {
        if (defined(this._copyDepthCommand)) {
            this._copyDepthCommand.execute(context, passState);
            context.uniformState.globeDepthTexture = this._globeDepthTexture;
        }
    };

    GlobeDepth.prototype.executeCopyColor = function(context, passState) {
        if (defined(this._copyColorCommand)) {
            this._copyColorCommand.execute(context, passState);
        }
    };

    GlobeDepth.prototype.clear = function(context, passState, clearColor) {
        var clear = this._clearColorCommand;
        if (defined(clear)) {
            Color.clone(clearColor, clear.color);
            clear.execute(context, passState);
        }
    };

    GlobeDepth.prototype.isDestroyed = function() {
        return false;
    };

    GlobeDepth.prototype.destroy = function() {
        destroyTextures(this);
        destroyFramebuffers(this);

        if (defined(this._copyColorCommand)) {
            this._copyColorCommand.shaderProgram = this._copyColorCommand.shaderProgram.destroy();
        }

        if (defined(this._copyDepthCommand)) {
            this._copyDepthCommand.shaderProgram = this._copyDepthCommand.shaderProgram.destroy();
        }

        var command = this._debugGlobeDepthViewportCommand;
        if (defined(command)) {
            command.shaderProgram = command.shaderProgram.destroy();
        }

        return destroyObject(this);
    };

    return GlobeDepth;
});
<|endoftext|>


<commit_before>'use strict'

const path = require('path')
const PROTO_PATH = path.join(__dirname, '../protos/localpets.proto')
const grpc = require('grpc')
const {localpets} = grpc.load(PROTO_PATH)
const client = new localpets.LocalPets('localhost:26570',
  grpc.credentials.createInsecure())
const test = require('tape')

test('create customer', t => {
  t.plan(2)

  const customer = {
    name: 'John Doe',
    prefBreeds: ['Cockerspaniel', 'Alaskan Malamute'],
    prefSpecies: ['turtle', 'cat'],
    prefMaxAge: 6
  }

  client.createCustomer(customer, (err, res) => {
    t.error(err, 'err is falsy')
    t.deepEqual(customer.prefSpecies, res.prefSpecies, 'saved document is equivalent')
  })
})

test('create pet', t => {
  t.plan(2)

  const pet = {
    name: 'Nymeria',
    breed: 'Direwolf',
    age: 15
  }

  client.createPet(pet, (err, res) => {
    t.error(err, 'err is falsy')
    t.equal(pet.name, res.name, 'saved document is equivalent')
  })
})

// TODO finish tests

test('get customer', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('get pet', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('list customers', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('list pets', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('find matching customers', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('find matching pets', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('delete customer', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('delete pet', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})

test('adopt pet', t => {
  t.plan(1)

  t.equal(true, true, 'true is true')
})
<commit_msg>Write tests<commit_after>'use strict'

const path = require('path')
const PROTO_PATH = path.join(__dirname, '../protos/localpets.proto')
const grpc = require('grpc')
const {localpets} = grpc.load(PROTO_PATH)
const client = new localpets.LocalPets('localhost:26570', grpc.credentials.createInsecure())
const test = require('tape')

test('create customer', t => {
  t.plan(1)

  const customer = {
    name: 'John Doe',
    prefBreeds: ['Cockerspaniel', 'Alaskan Malamute'],
    prefSpecies: ['turtle', 'cat'],
    prefMaxAge: 6
  }
  client.createCustomer(customer, (err, doc) => {
    if (err) {
      return t.error(err, 'no error')
    }
    t.deepEqual(customer.prefSpecies, doc.prefSpecies, 'should be equivalent')
  })
})

test('create pet', t => {
  t.plan(1)

  const pet = {
    name: 'Nymeria',
    breed: 'Direwolf',
    age: 15
  }
  client.createPet(pet, (err, {name, breed, age}) => {
    if (err) {
      return t.error(err, 'no error')
    }
    t.equal(pet, {name, breed, age}, 'should be equivalent')
  })
})

test('get customer', t => {
  t.plan(1)

  const customer = {name: 'Viserys'}
  client.createCustomer(customer, (err, {_id}) => {
    if (err) {
      return t.error(err, 'no error')
    }
    client.getCustomer({_id}, (err, doc) => {
      if (err) {
        return t.error(err, 'no error')
      }
      t.deepEqual(customer.name, doc.name, 'should be equivalent')
    })
  })
})

test('get pet', t => {
  t.plan(1)

  const pet = {species: 'cat', age: 5}
  client.createPet(pet, (err, {_id}) => {
    if (err) {
      return t.error(err, 'no error')
    }
    client.getCustomer({_id}, (err, {species, age}) => {
      if (err) {
        return t.error(err, 'no error')
      }
      t.deepEqual(pet, {species, age}, 'should be equivalent')
    })
  })
})

test('list customers', t => {
  t.plan(1)

  const stream = client.listCustomers({})
  const customers = []
  stream
    .on('data', doc => customers.push(doc))
    .on('error', err => t.error(err, 'no error'))
    .on('end', () => {
      const [first] = customers
      t.ok(first.name.length > 0, 'first customer should have a name')
    })
})

test('list pets', t => {
  t.plan(1)

  const stream = client.listPets({})
  const pets = []
  stream
    .on('data', doc => pets.push(doc))
    .on('error', err => t.error(err, 'no error'))
    .on('end', () => {
      const [first] = pets
      t.ok(first.name.length > 0, 'first pet should have a species')
    })
})

test('find matching customers for first pet', t => {
  t.plan(2)

  const petStream = client.listPets({limit: 1})
  const pets = []
  petStream
    .on('data', doc => pets.push(doc))
    .on('error', err => t.error(err, 'no error'))
    .on('end', () => {
      t.equal(pets.length, 1, 'only one pet should be returned')
      const [firstPet] = pets
      const customers = []
      const customerStream = client.findCustomers({_id: firstPet._id})
      customerStream
        .on('data', doc => customers.push(doc))
        .on('error', err => t.error(err, 'no error'))
        .on('end', () => {
          const [firstCustomer] = customers
          t.ok(firstCustomer.name.length > 0, 'first customer found should have a name')
        })
    })
})

test('find matching pets for first customer', t => {
  t.plan(2)

  const customerStream = client.listCustomers({limit: 1})
  const customers = []
  customerStream
    .on('data', doc => customers.push(doc))
    .on('error', err => t.error(err, 'no error'))
    .on('end', () => {
      t.equal(customers.length, 1, 'only one customer should be returned')
      const [firstCustomer] = customers
      const pets = []
      const petStream = client.findPets({_id: firstCustomer._id})
      petStream
        .on('data', doc => pets.push(doc))
        .on('error', err => t.error(err, 'no error'))
        .on('end', () => {
          const [firstPet] = pets
          t.ok(firstPet.species.length > 0, 'first pet found should have a species')
        })
    })
})

test('delete first customer', t => {
  t.plan(2)

  const customerStream = client.listCustomers({limit: 1})
  const customers = []
  customerStream
    .on('data', doc => customers.push(doc))
    .on('error', err => t.error(err, 'no error'))
    .on('end', () => {
      t.equal(customers.length, 1, 'only one customer should be returned')
      const [firstCustomer] = customers
      client.deleteCustomer({_id: firstCustomer._id}, err => {
        t.error(err, 'no error')
      })
    })
})

test('delete first pet', t => {
  t.plan(2)

  const petStream = client.listPets({limit: 1})
  const pets = []
  petStream
    .on('data', doc => pets.push(doc))
    .on('error', err => t.error(err, 'no error'))
    .on('end', () => {
      t.equal(pets.length, 1, 'only one pet should be returned')
      const [firstPet] = pets
      client.deletePet({_id: firstPet._id}, err => {
        t.error(err, 'no error')
      })
    })
})

test('new customer adopts new pet', t => {
  t.plan(1)

  const customer = {
    name: 'Jon Snow',
    prefBreeds: ['Direwolf', 'Alaskan Malamute'],
    prefSpecies: ['turtle', 'cat'],
    prefMaxAge: 6
  }
  client.createCustomer(customer, (err, doc) => {
    if (err) {
      return t.error(err, 'no error')
    }
    const customerId = doc._id
    const pet = {
      name: 'Shadow',
      breed: 'Direwolf',
      age: 15
    }
    client.createPet(pet, (err, doc) => {
      if (err) {
        return t.error(err, 'no error')
      }
      const petId = doc._id
      client.adoptPet({pet: {_id: petId}, customer: {_id: customerId}}, (err, doc) => {
        if (err) {
          return t.error(err, 'no error')
        }
        t.equal(doc.adoptedBy, customerId, 'pet should be adopted by customer')
      })
    })
  })
})
<|endoftext|>


<commit_before>import React from "react";
import { connect } from "react-redux";
import { doChangeVolume } from "redux/actions/app";
import { selectVolume } from "redux/selectors/app";
import { doPlayUri, doSetPlayingUri } from "redux/actions/content";
import { doPlay, doPause, savePosition } from "redux/actions/media";
import {
  makeSelectMetadataForUri,
  makeSelectContentTypeForUri,
} from "redux/selectors/claims";
import {
  makeSelectFileInfoForUri,
  makeSelectLoadingForUri,
  makeSelectDownloadingForUri,
} from "redux/selectors/file_info";
import { makeSelectCostInfoForUri } from "redux/selectors/cost_info";
import { selectShowNsfw } from "redux/selectors/settings";
import {
  selectMediaPaused,
  makeSelectMediaPositionForUri,
} from "redux/selectors/media";
import Video from "./view";
import { selectPlayingUri } from "redux/selectors/content";
import { makeSelectClaimForUri } from "redux/selectors/claims";

const select = (state, props) => ({
  claim: makeSelectClaimForUri(props.uri)(state),
  costInfo: makeSelectCostInfoForUri(props.uri)(state),
  fileInfo: makeSelectFileInfoForUri(props.uri)(state),
  metadata: makeSelectMetadataForUri(props.uri)(state),
  obscureNsfw: !selectShowNsfw(state),
  isLoading: makeSelectLoadingForUri(props.uri)(state),
  isDownloading: makeSelectDownloadingForUri(props.uri)(state),
  playingUri: selectPlayingUri(state),
  contentType: makeSelectContentTypeForUri(props.uri)(state),
  volume: selectVolume(state),
  mediaPaused: selectMediaPaused(state),
  mediaPosition: makeSelectMediaPositionForUri(props.uri)(state),
});

const perform = dispatch => ({
  play: uri => dispatch(doPlayUri(uri)),
  cancelPlay: () => dispatch(doSetPlayingUri(null)),
  changeVolume: volume => dispatch(doChangeVolume(volume)),
  doPlay: () => dispatch(doPlay()),
  doPause: () => dispatch(doPause()),
  savePosition: (id, position) => dispatch(savePosition(id, position)),
});

export default connect(select, perform)(Video);
<commit_msg>rename id param to claimId<commit_after>import React from "react";
import { connect } from "react-redux";
import { doChangeVolume } from "redux/actions/app";
import { selectVolume } from "redux/selectors/app";
import { doPlayUri, doSetPlayingUri } from "redux/actions/content";
import { doPlay, doPause, savePosition } from "redux/actions/media";
import {
  makeSelectMetadataForUri,
  makeSelectContentTypeForUri,
} from "redux/selectors/claims";
import {
  makeSelectFileInfoForUri,
  makeSelectLoadingForUri,
  makeSelectDownloadingForUri,
} from "redux/selectors/file_info";
import { makeSelectCostInfoForUri } from "redux/selectors/cost_info";
import { selectShowNsfw } from "redux/selectors/settings";
import {
  selectMediaPaused,
  makeSelectMediaPositionForUri,
} from "redux/selectors/media";
import Video from "./view";
import { selectPlayingUri } from "redux/selectors/content";
import { makeSelectClaimForUri } from "redux/selectors/claims";

const select = (state, props) => ({
  claim: makeSelectClaimForUri(props.uri)(state),
  costInfo: makeSelectCostInfoForUri(props.uri)(state),
  fileInfo: makeSelectFileInfoForUri(props.uri)(state),
  metadata: makeSelectMetadataForUri(props.uri)(state),
  obscureNsfw: !selectShowNsfw(state),
  isLoading: makeSelectLoadingForUri(props.uri)(state),
  isDownloading: makeSelectDownloadingForUri(props.uri)(state),
  playingUri: selectPlayingUri(state),
  contentType: makeSelectContentTypeForUri(props.uri)(state),
  volume: selectVolume(state),
  mediaPaused: selectMediaPaused(state),
  mediaPosition: makeSelectMediaPositionForUri(props.uri)(state),
});

const perform = dispatch => ({
  play: uri => dispatch(doPlayUri(uri)),
  cancelPlay: () => dispatch(doSetPlayingUri(null)),
  changeVolume: volume => dispatch(doChangeVolume(volume)),
  doPlay: () => dispatch(doPlay()),
  doPause: () => dispatch(doPause()),
  savePosition: (claimId, position) =>
    dispatch(savePosition(claimId, position)),
});

export default connect(select, perform)(Video);
<|endoftext|>


<commit_before>/**
 * @author       Richard Davey <rich@photonstorm.com>
 * @copyright    2020 Photon Storm Ltd.
 * @license      {@link https://opensource.org/licenses/MIT|MIT License}
 */

var PIPELINE_CONST = {

    /**
     * The Bitmap Mask Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.BITMAPMASK_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    BITMAPMASK_PIPELINE: 'BitmapMaskPipeline',

    /**
     * The Light 2D Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.LIGHT_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    LIGHT_PIPELINE: 'Light2D',

    /**
     * The Single Texture Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.SINGLE_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    SINGLE_PIPELINE: 'SinglePipeline',

    /**
     * The Multi Texture Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.MULTI_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    MULTI_PIPELINE: 'MultiPipeline',

    /**
     * The Rope Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.ROPE_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    ROPE_PIPELINE: 'RopePipeline',

    /**
     * The Graphics and Shapes Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.GRAPHICS_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    GRAPHICS_PIPELINE: 'GraphicsPipeline',

    /**
     * The Post FX Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.POSTFX_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    POSTFX_PIPELINE: 'PostFXPipeline',

    /**
     * The Utility Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.UTILITY_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    UTILITY_PIPELINE: 'UtilityPipeline'
};

module.exports = PIPELINE_CONST;
<commit_msg>Added Point Light Pipeline to the const<commit_after>/**
 * @author       Richard Davey <rich@photonstorm.com>
 * @copyright    2020 Photon Storm Ltd.
 * @license      {@link https://opensource.org/licenses/MIT|MIT License}
 */

var PIPELINE_CONST = {

    /**
     * The Bitmap Mask Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.BITMAPMASK_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    BITMAPMASK_PIPELINE: 'BitmapMaskPipeline',

    /**
     * The Light 2D Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.LIGHT_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    LIGHT_PIPELINE: 'Light2D',

    /**
     * The Point Light Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.POINTLIGHT_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    POINTLIGHT_PIPELINE: 'PointLightPipeline',

    /**
     * The Single Texture Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.SINGLE_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    SINGLE_PIPELINE: 'SinglePipeline',

    /**
     * The Multi Texture Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.MULTI_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    MULTI_PIPELINE: 'MultiPipeline',

    /**
     * The Rope Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.ROPE_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    ROPE_PIPELINE: 'RopePipeline',

    /**
     * The Graphics and Shapes Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.GRAPHICS_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    GRAPHICS_PIPELINE: 'GraphicsPipeline',

    /**
     * The Post FX Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.POSTFX_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    POSTFX_PIPELINE: 'PostFXPipeline',

    /**
     * The Utility Pipeline.
     *
     * @name Phaser.Renderer.WebGL.Pipelines.UTILITY_PIPELINE
     * @type {string}
     * @const
     * @since 3.50.0
     */
    UTILITY_PIPELINE: 'UtilityPipeline'
};

module.exports = PIPELINE_CONST;
<|endoftext|>


<commit_before>/**
 * @author alteredq / http://alteredqualia.com/
 * @author mrdoob / http://mrdoob.com/
 */

THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {

	var _gl = _renderer.context,
	_state = _renderer.state,
	_frustum = new THREE.Frustum(),
	_projScreenMatrix = new THREE.Matrix4(),

	_shadowMapSize = new THREE.Vector2(),

	_lookTarget = new THREE.Vector3(),
	_lightPositionWorld = new THREE.Vector3(),

	_renderList = [],

	_MorphingFlag = 1,
	_SkinningFlag = 2,

	_NumberOfMaterialVariants = ( _MorphingFlag | _SkinningFlag ) + 1,

	_depthMaterials = new Array( _NumberOfMaterialVariants ),
	_distanceMaterials = new Array( _NumberOfMaterialVariants );

	var cubeDirections = [
		new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( - 1, 0, 0 ), new THREE.Vector3( 0, 0, 1 ),
		new THREE.Vector3( 0, 0, - 1 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, - 1, 0 )
	];

	var cubeUps = [
		new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ),
		new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ),	new THREE.Vector3( 0, 0, - 1 )
	];

	var cube2DViewPorts = [
		new THREE.Vector4(), new THREE.Vector4(), new THREE.Vector4(),
		new THREE.Vector4(), new THREE.Vector4(), new THREE.Vector4()
	];

	// init

	var depthShader = THREE.ShaderLib[ "depthRGBA" ];
	var depthUniforms = THREE.UniformsUtils.clone( depthShader.uniforms );

	var distanceShader = THREE.ShaderLib[ "distanceRGBA" ];
	var distanceUniforms = THREE.UniformsUtils.clone( distanceShader.uniforms );

	for ( var i = 0; i !== _NumberOfMaterialVariants; ++ i ) {

		var useMorphing = ( i & _MorphingFlag ) !== 0;
		var useSkinning = ( i & _SkinningFlag ) !== 0;

		var depthMaterial = new THREE.ShaderMaterial( {
			uniforms: depthUniforms,
			vertexShader: depthShader.vertexShader,
			fragmentShader: depthShader.fragmentShader,
			morphTargets: useMorphing,
			skinning: useSkinning
		} );

		_depthMaterials[ i ] = depthMaterial;

		var distanceMaterial = new THREE.ShaderMaterial( {
			defines: {
				'USE_SHADOWMAP': ''
			},
			uniforms: distanceUniforms,
			vertexShader: distanceShader.vertexShader,
			fragmentShader: distanceShader.fragmentShader,
			morphTargets: useMorphing,
			skinning: useSkinning
		} );

		_distanceMaterials[ i ] = distanceMaterial;

	}

	//

	var scope = this;

	this.enabled = false;

	this.autoUpdate = true;
	this.needsUpdate = false;

	this.type = THREE.PCFShadowMap;
	this.cullFace = THREE.CullFaceFront;

	this.render = function ( scene, camera ) {

		var faceCount, isPointLight;

		if ( scope.enabled === false ) return;
		if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;

		// Set GL state for depth map.
		_state.clearColor( 1, 1, 1, 1 );
		_state.disable( _gl.BLEND );
		_state.enable( _gl.CULL_FACE );
		_gl.frontFace( _gl.CCW );
		_gl.cullFace( scope.cullFace === THREE.CullFaceFront ? _gl.FRONT : _gl.BACK );
		_state.setDepthTest( true );
		_state.setScissorTest( false );

		// render depth map

		var shadows = _lights.shadows;

		for ( var i = 0, il = shadows.length; i < il; i ++ ) {

			var light = shadows[ i ];

			var shadow = light.shadow;
			var shadowCamera = shadow.camera;

			_shadowMapSize.copy( shadow.mapSize );

			if ( light instanceof THREE.PointLight ) {

				faceCount = 6;
				isPointLight = true;

				var vpWidth = _shadowMapSize.x;
				var vpHeight = _shadowMapSize.y;

				// These viewports map a cube-map onto a 2D texture with the
				// following orientation:
				//
				//  xzXZ
				//   y Y
				//
				// X - Positive x direction
				// x - Negative x direction
				// Y - Positive y direction
				// y - Negative y direction
				// Z - Positive z direction
				// z - Negative z direction

				// positive X
				cube2DViewPorts[ 0 ].set( vpWidth * 2, vpHeight, vpWidth, vpHeight );
				// negative X
				cube2DViewPorts[ 1 ].set( 0, vpHeight, vpWidth, vpHeight );
				// positive Z
				cube2DViewPorts[ 2 ].set( vpWidth * 3, vpHeight, vpWidth, vpHeight );
				// negative Z
				cube2DViewPorts[ 3 ].set( vpWidth, vpHeight, vpWidth, vpHeight );
				// positive Y
				cube2DViewPorts[ 4 ].set( vpWidth * 3, 0, vpWidth, vpHeight );
				// negative Y
				cube2DViewPorts[ 5 ].set( vpWidth, 0, vpWidth, vpHeight );

				_shadowMapSize.x *= 4.0;
				_shadowMapSize.y *= 2.0;

			} else {

				faceCount = 1;
				isPointLight = false;

			}

			if ( shadow.map === null ) {

				var pars = { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat };

				shadow.map = new THREE.WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );

				//

				if ( light instanceof THREE.SpotLight ) {

					shadowCamera.aspect = _shadowMapSize.x / _shadowMapSize.y;

				}

				shadowCamera.updateProjectionMatrix();

			}

			var shadowMap = shadow.map;
			var shadowMatrix = shadow.matrix;

			_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
			shadowCamera.position.copy( _lightPositionWorld );

			_renderer.setRenderTarget( shadowMap );
			_renderer.clear();

			// render shadow map for each cube face (if omni-directional) or
			// run a single pass if not

			for ( var face = 0; face < faceCount; face ++ ) {

				if ( isPointLight ) {

					_lookTarget.copy( shadowCamera.position );
					_lookTarget.add( cubeDirections[ face ] );
					shadowCamera.up.copy( cubeUps[ face ] );
					shadowCamera.lookAt( _lookTarget );

					var vpDimensions = cube2DViewPorts[ face ];
					_state.viewport( vpDimensions );

				} else {

					_lookTarget.setFromMatrixPosition( light.target.matrixWorld );
					shadowCamera.lookAt( _lookTarget );

				}

				shadowCamera.updateMatrixWorld();
				shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );

				// compute shadow matrix

				shadowMatrix.set(
					0.5, 0.0, 0.0, 0.5,
					0.0, 0.5, 0.0, 0.5,
					0.0, 0.0, 0.5, 0.5,
					0.0, 0.0, 0.0, 1.0
				);

				shadowMatrix.multiply( shadowCamera.projectionMatrix );
				shadowMatrix.multiply( shadowCamera.matrixWorldInverse );

				// update camera matrices and frustum

				_projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
				_frustum.setFromMatrix( _projScreenMatrix );

				// set object matrices & frustum culling

				_renderList.length = 0;

				projectObject( scene, camera, shadowCamera );

				// render shadow map
				// render regular objects

				for ( var j = 0, jl = _renderList.length; j < jl; j ++ ) {

					var object = _renderList[ j ];
					var geometry = _objects.update( object );
					var material = object.material;

					if ( material instanceof THREE.MultiMaterial ) {

						var groups = geometry.groups;
						var materials = material.materials;

						for ( var k = 0, kl = groups.length; k < kl; k ++ ) {

							var group = groups[ k ];
							var groupMaterial = materials[ group.materialIndex ];

							if ( groupMaterial.visible === true ) {

								var depthMaterial = getDepthMaterial( object, groupMaterial, isPointLight, _lightPositionWorld );
								_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );

							}

						}

					} else {

						var depthMaterial = getDepthMaterial( object, material, isPointLight, _lightPositionWorld );
						_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );

					}

				}

			}

			// We must call _renderer.resetGLState() at the end of each iteration of
			// the light loop in order to force material updates for each light.
			_renderer.resetGLState();

		}

		// Restore GL state.
		var clearColor = _renderer.getClearColor(),
		clearAlpha = _renderer.getClearAlpha();
		_renderer.setClearColor( clearColor, clearAlpha );

		_state.enable( _gl.BLEND );

		if ( scope.cullFace === THREE.CullFaceFront ) {

			_gl.cullFace( _gl.BACK );

		}

		_renderer.resetGLState();

		scope.needsUpdate = false;

	};

	function getDepthMaterial( object, material, isPointLight, lightPositionWorld ) {

		var geometry = object.geometry;

		var newMaterial = null;

		var materialVariants = _depthMaterials;
		var customMaterial = object.customDepthMaterial;

		if ( isPointLight ) {

			materialVariants = _distanceMaterials;
			customMaterial = object.customDistanceMaterial;

		}

		if ( ! customMaterial ) {

			var useMorphing = geometry.morphTargets !== undefined &&
					geometry.morphTargets.length > 0 && material.morphTargets;

			var useSkinning = object instanceof THREE.SkinnedMesh && material.skinning;

			var variantIndex = 0;

			if ( useMorphing ) variantIndex |= _MorphingFlag;
			if ( useSkinning ) variantIndex |= _SkinningFlag;

			newMaterial = materialVariants[ variantIndex ];

		} else {

			newMaterial = customMaterial;

		}

		newMaterial.visible = material.visible;
		newMaterial.wireframe = material.wireframe;
		newMaterial.wireframeLinewidth = material.wireframeLinewidth;

		if ( isPointLight && newMaterial.uniforms.lightPos !== undefined ) {

			newMaterial.uniforms.lightPos.value.copy( lightPositionWorld );

		}

		return newMaterial;

	}

	function projectObject( object, camera, shadowCamera ) {

		if ( object.visible === false ) return;

		if ( object.layers.test( camera.layers ) && ( object instanceof THREE.Mesh || object instanceof THREE.Line || object instanceof THREE.Points ) ) {

			if ( object.castShadow && ( object.frustumCulled === false || _frustum.intersectsObject( object ) === true ) ) {

				var material = object.material;

				if ( material.visible === true ) {

					object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
					_renderList.push( object );

				}

			}

		}

		var children = object.children;

		for ( var i = 0, l = children.length; i < l; i ++ ) {

			projectObject( children[ i ], camera, shadowCamera );

		}

	}

};
<commit_msg>WebGLShadowMap: Avoid changing state when shadowMap is enabled but there are not light with shadows in the scene.<commit_after>/**
 * @author alteredq / http://alteredqualia.com/
 * @author mrdoob / http://mrdoob.com/
 */

THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {

	var _gl = _renderer.context,
	_state = _renderer.state,
	_frustum = new THREE.Frustum(),
	_projScreenMatrix = new THREE.Matrix4(),

	_shadowMapSize = new THREE.Vector2(),

	_lookTarget = new THREE.Vector3(),
	_lightPositionWorld = new THREE.Vector3(),

	_renderList = [],

	_MorphingFlag = 1,
	_SkinningFlag = 2,

	_NumberOfMaterialVariants = ( _MorphingFlag | _SkinningFlag ) + 1,

	_depthMaterials = new Array( _NumberOfMaterialVariants ),
	_distanceMaterials = new Array( _NumberOfMaterialVariants );

	var cubeDirections = [
		new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( - 1, 0, 0 ), new THREE.Vector3( 0, 0, 1 ),
		new THREE.Vector3( 0, 0, - 1 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, - 1, 0 )
	];

	var cubeUps = [
		new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 1, 0 ),
		new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ),	new THREE.Vector3( 0, 0, - 1 )
	];

	var cube2DViewPorts = [
		new THREE.Vector4(), new THREE.Vector4(), new THREE.Vector4(),
		new THREE.Vector4(), new THREE.Vector4(), new THREE.Vector4()
	];

	// init

	var depthShader = THREE.ShaderLib[ "depthRGBA" ];
	var depthUniforms = THREE.UniformsUtils.clone( depthShader.uniforms );

	var distanceShader = THREE.ShaderLib[ "distanceRGBA" ];
	var distanceUniforms = THREE.UniformsUtils.clone( distanceShader.uniforms );

	for ( var i = 0; i !== _NumberOfMaterialVariants; ++ i ) {

		var useMorphing = ( i & _MorphingFlag ) !== 0;
		var useSkinning = ( i & _SkinningFlag ) !== 0;

		var depthMaterial = new THREE.ShaderMaterial( {
			uniforms: depthUniforms,
			vertexShader: depthShader.vertexShader,
			fragmentShader: depthShader.fragmentShader,
			morphTargets: useMorphing,
			skinning: useSkinning
		} );

		_depthMaterials[ i ] = depthMaterial;

		var distanceMaterial = new THREE.ShaderMaterial( {
			defines: {
				'USE_SHADOWMAP': ''
			},
			uniforms: distanceUniforms,
			vertexShader: distanceShader.vertexShader,
			fragmentShader: distanceShader.fragmentShader,
			morphTargets: useMorphing,
			skinning: useSkinning
		} );

		_distanceMaterials[ i ] = distanceMaterial;

	}

	//

	var scope = this;

	this.enabled = false;

	this.autoUpdate = true;
	this.needsUpdate = false;

	this.type = THREE.PCFShadowMap;
	this.cullFace = THREE.CullFaceFront;

	this.render = function ( scene, camera ) {

		var faceCount, isPointLight;
		var shadows = _lights.shadows;

		if ( shadows.length === 0 ) return;

		if ( scope.enabled === false ) return;
		if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;

		// Set GL state for depth map.
		_state.clearColor( 1, 1, 1, 1 );
		_state.disable( _gl.BLEND );
		_state.enable( _gl.CULL_FACE );
		_gl.frontFace( _gl.CCW );
		_gl.cullFace( scope.cullFace === THREE.CullFaceFront ? _gl.FRONT : _gl.BACK );
		_state.setDepthTest( true );
		_state.setScissorTest( false );

		// render depth map

		for ( var i = 0, il = shadows.length; i < il; i ++ ) {

			var light = shadows[ i ];

			var shadow = light.shadow;
			var shadowCamera = shadow.camera;

			_shadowMapSize.copy( shadow.mapSize );

			if ( light instanceof THREE.PointLight ) {

				faceCount = 6;
				isPointLight = true;

				var vpWidth = _shadowMapSize.x;
				var vpHeight = _shadowMapSize.y;

				// These viewports map a cube-map onto a 2D texture with the
				// following orientation:
				//
				//  xzXZ
				//   y Y
				//
				// X - Positive x direction
				// x - Negative x direction
				// Y - Positive y direction
				// y - Negative y direction
				// Z - Positive z direction
				// z - Negative z direction

				// positive X
				cube2DViewPorts[ 0 ].set( vpWidth * 2, vpHeight, vpWidth, vpHeight );
				// negative X
				cube2DViewPorts[ 1 ].set( 0, vpHeight, vpWidth, vpHeight );
				// positive Z
				cube2DViewPorts[ 2 ].set( vpWidth * 3, vpHeight, vpWidth, vpHeight );
				// negative Z
				cube2DViewPorts[ 3 ].set( vpWidth, vpHeight, vpWidth, vpHeight );
				// positive Y
				cube2DViewPorts[ 4 ].set( vpWidth * 3, 0, vpWidth, vpHeight );
				// negative Y
				cube2DViewPorts[ 5 ].set( vpWidth, 0, vpWidth, vpHeight );

				_shadowMapSize.x *= 4.0;
				_shadowMapSize.y *= 2.0;

			} else {

				faceCount = 1;
				isPointLight = false;

			}

			if ( shadow.map === null ) {

				var pars = { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat };

				shadow.map = new THREE.WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );

				//

				if ( light instanceof THREE.SpotLight ) {

					shadowCamera.aspect = _shadowMapSize.x / _shadowMapSize.y;

				}

				shadowCamera.updateProjectionMatrix();

			}

			var shadowMap = shadow.map;
			var shadowMatrix = shadow.matrix;

			_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
			shadowCamera.position.copy( _lightPositionWorld );

			_renderer.setRenderTarget( shadowMap );
			_renderer.clear();

			// render shadow map for each cube face (if omni-directional) or
			// run a single pass if not

			for ( var face = 0; face < faceCount; face ++ ) {

				if ( isPointLight ) {

					_lookTarget.copy( shadowCamera.position );
					_lookTarget.add( cubeDirections[ face ] );
					shadowCamera.up.copy( cubeUps[ face ] );
					shadowCamera.lookAt( _lookTarget );

					var vpDimensions = cube2DViewPorts[ face ];
					_state.viewport( vpDimensions );

				} else {

					_lookTarget.setFromMatrixPosition( light.target.matrixWorld );
					shadowCamera.lookAt( _lookTarget );

				}

				shadowCamera.updateMatrixWorld();
				shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );

				// compute shadow matrix

				shadowMatrix.set(
					0.5, 0.0, 0.0, 0.5,
					0.0, 0.5, 0.0, 0.5,
					0.0, 0.0, 0.5, 0.5,
					0.0, 0.0, 0.0, 1.0
				);

				shadowMatrix.multiply( shadowCamera.projectionMatrix );
				shadowMatrix.multiply( shadowCamera.matrixWorldInverse );

				// update camera matrices and frustum

				_projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
				_frustum.setFromMatrix( _projScreenMatrix );

				// set object matrices & frustum culling

				_renderList.length = 0;

				projectObject( scene, camera, shadowCamera );

				// render shadow map
				// render regular objects

				for ( var j = 0, jl = _renderList.length; j < jl; j ++ ) {

					var object = _renderList[ j ];
					var geometry = _objects.update( object );
					var material = object.material;

					if ( material instanceof THREE.MultiMaterial ) {

						var groups = geometry.groups;
						var materials = material.materials;

						for ( var k = 0, kl = groups.length; k < kl; k ++ ) {

							var group = groups[ k ];
							var groupMaterial = materials[ group.materialIndex ];

							if ( groupMaterial.visible === true ) {

								var depthMaterial = getDepthMaterial( object, groupMaterial, isPointLight, _lightPositionWorld );
								_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );

							}

						}

					} else {

						var depthMaterial = getDepthMaterial( object, material, isPointLight, _lightPositionWorld );
						_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );

					}

				}

			}

			// We must call _renderer.resetGLState() at the end of each iteration of
			// the light loop in order to force material updates for each light.
			_renderer.resetGLState();

		}

		// Restore GL state.
		var clearColor = _renderer.getClearColor(),
		clearAlpha = _renderer.getClearAlpha();
		_renderer.setClearColor( clearColor, clearAlpha );

		_state.enable( _gl.BLEND );

		if ( scope.cullFace === THREE.CullFaceFront ) {

			_gl.cullFace( _gl.BACK );

		}

		_renderer.resetGLState();

		scope.needsUpdate = false;

	};

	function getDepthMaterial( object, material, isPointLight, lightPositionWorld ) {

		var geometry = object.geometry;

		var newMaterial = null;

		var materialVariants = _depthMaterials;
		var customMaterial = object.customDepthMaterial;

		if ( isPointLight ) {

			materialVariants = _distanceMaterials;
			customMaterial = object.customDistanceMaterial;

		}

		if ( ! customMaterial ) {

			var useMorphing = geometry.morphTargets !== undefined &&
					geometry.morphTargets.length > 0 && material.morphTargets;

			var useSkinning = object instanceof THREE.SkinnedMesh && material.skinning;

			var variantIndex = 0;

			if ( useMorphing ) variantIndex |= _MorphingFlag;
			if ( useSkinning ) variantIndex |= _SkinningFlag;

			newMaterial = materialVariants[ variantIndex ];

		} else {

			newMaterial = customMaterial;

		}

		newMaterial.visible = material.visible;
		newMaterial.wireframe = material.wireframe;
		newMaterial.wireframeLinewidth = material.wireframeLinewidth;

		if ( isPointLight && newMaterial.uniforms.lightPos !== undefined ) {

			newMaterial.uniforms.lightPos.value.copy( lightPositionWorld );

		}

		return newMaterial;

	}

	function projectObject( object, camera, shadowCamera ) {

		if ( object.visible === false ) return;

		if ( object.layers.test( camera.layers ) && ( object instanceof THREE.Mesh || object instanceof THREE.Line || object instanceof THREE.Points ) ) {

			if ( object.castShadow && ( object.frustumCulled === false || _frustum.intersectsObject( object ) === true ) ) {

				var material = object.material;

				if ( material.visible === true ) {

					object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
					_renderList.push( object );

				}

			}

		}

		var children = object.children;

		for ( var i = 0, l = children.length; i < l; i ++ ) {

			projectObject( children[ i ], camera, shadowCamera );

		}

	}

};
<|endoftext|>


<commit_before>/* eslint no-cond-assign: 0 */

import {
  ExtensionRegistry,
  MessageViewExtension,
  ComposerExtension,
  RegExpUtils,
} from 'nylas-exports';

const TrackingBlacklist = [{
  name: 'Sidekick',
  pattern: 't.signaux',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Sidekick',
  pattern: 't.senal',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Sidekick',
  pattern: 't.sidekickopen',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Sidekick',
  pattern: 't.sigopn',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Banana Tag',
  pattern: 'bl-1.com',
  homepage: 'http://bananatag.com',
}, {
  name: 'Boomerang',
  pattern: 'mailstat.us/tr',
  homepage: 'http://boomeranggmail.com',
}, {
  name: 'Cirrus Inisght',
  pattern: 'tracking.cirrusinsight.com',
  homepage: 'http://cirrusinsight.com',
}, {
  name: 'Yesware',
  pattern: 'app.yesware.com',
  homepage: 'http://yesware.com',
}, {
  name: 'Yesware',
  pattern: 't.yesware.com',
  homepage: 'http://yesware.com',
}, {
  name: 'Streak',
  pattern: 'mailfoogae.appspot.com',
  homepage: 'http://streak.com',
}, {
  name: 'LaunchBit',
  pattern: 'launchbit.com/taz-pixel',
  homepage: 'http://launchbit.com',
}, {
  name: 'MailChimp',
  pattern: 'list-manage.com/track',
  homepage: 'http://mailchimp.com',
}, {
  name: 'Postmark',
  pattern: 'cmail1.com/t',
  homepage: 'http://postmarkapp.com',
}, {
  name: 'iContact',
  pattern: 'click.icptrack.com/icp/',
  homepage: 'http://icontact.com',
}, {
  name: 'Infusionsoft',
  pattern: 'infusionsoft.com/app/emailOpened',
  homepage: 'http://infusionsoft.com',
}, {
  name: 'Intercom',
  pattern: 'via.intercom.io/o',
  homepage: 'http://intercom.io',
}, {
  name: 'Mandrill',
  pattern: 'mandrillapp.com/track',
  homepage: 'http://mandrillapp.com',
}, {
  name: 'Hubspot',
  pattern: 't.hsms06.com',
  homepage: 'http://hubspot.com',
}, {
  name: 'RelateIQ',
  pattern: 'app.relateiq.com/t.png',
  homepage: 'http://relateiq.com',
}, {
  name: 'RJ Metrics',
  pattern: 'go.rjmetrics.com',
  homepage: 'http://rjmetrics.com',
}, {
  name: 'Mixpanel',
  pattern: 'api.mixpanel.com/track',
  homepage: 'http://mixpanel.com',
}, {
  name: 'Front App',
  pattern: 'web.frontapp.com/api',
  homepage: 'http://frontapp.com',
}, {
  name: 'Mailtrack.io',
  pattern: 'mailtrack.io/trace',
  homepage: 'http://mailtrack.io',
}, {
  name: 'Salesloft',
  pattern: 'sdr.salesloft.com/email_trackers',
  homepage: 'http://salesloft.com',
}, {
  name: 'Nylas',
  pattern: 'nylas.com/open',
  homepage: 'http://nylas.com/N1',
}]

export function removeTrackingImagesFromBody(body) {
  const spliceRegions = [];
  const regex = RegExpUtils.imageTagRegex();

  // Identify img tags that should be cut
  let result = null;
  while ((result = regex.exec(body)) !== null) {
    for (const item of TrackingBlacklist) {
      if (result[1].indexOf(item.pattern) > 0) {
        spliceRegions.push({start: result.index, end: result.index + result[0].length})
        continue;
      }
    }
  }
  // Remove them all, from the end of the string to the start
  let updated = body;
  spliceRegions.reverse().forEach(({start, end}) => {
    updated = updated.substr(0, start) + updated.substr(end);
  });

  return updated;
}

class TrackingPixelsMessageExtension extends MessageViewExtension {
  formatMessageBody({message}) {
    if (message.isFromMe()) {
      message.body = removeTrackingImagesFromBody(message.body);
    }
  }
}

class TrackingPixelsComposerExtension extends ComposerExtension {
  static prepareNewDraft = ({draft}) => {
    draft.body = removeTrackingImagesFromBody(draft.body);
  }
}

export function activate() {
  ExtensionRegistry.MessageView.register(TrackingPixelsMessageExtension);
  ExtensionRegistry.Composer.register(TrackingPixelsComposerExtension);
}

export function deactivate() {
  ExtensionRegistry.MessageView.unregister(TrackingPixelsMessageExtension);
  ExtensionRegistry.Composer.unregister(TrackingPixelsComposerExtension);
}
<commit_msg>fix(read-receipts): Fix another issue caused by ES6 subclassing Coffeescript<commit_after>/* eslint no-cond-assign: 0 */

import {
  ExtensionRegistry,
  MessageViewExtension,
  ComposerExtension,
  RegExpUtils,
} from 'nylas-exports';

const TrackingBlacklist = [{
  name: 'Sidekick',
  pattern: 't.signaux',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Sidekick',
  pattern: 't.senal',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Sidekick',
  pattern: 't.sidekickopen',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Sidekick',
  pattern: 't.sigopn',
  homepage: 'http://getsidekick.com',
}, {
  name: 'Banana Tag',
  pattern: 'bl-1.com',
  homepage: 'http://bananatag.com',
}, {
  name: 'Boomerang',
  pattern: 'mailstat.us/tr',
  homepage: 'http://boomeranggmail.com',
}, {
  name: 'Cirrus Inisght',
  pattern: 'tracking.cirrusinsight.com',
  homepage: 'http://cirrusinsight.com',
}, {
  name: 'Yesware',
  pattern: 'app.yesware.com',
  homepage: 'http://yesware.com',
}, {
  name: 'Yesware',
  pattern: 't.yesware.com',
  homepage: 'http://yesware.com',
}, {
  name: 'Streak',
  pattern: 'mailfoogae.appspot.com',
  homepage: 'http://streak.com',
}, {
  name: 'LaunchBit',
  pattern: 'launchbit.com/taz-pixel',
  homepage: 'http://launchbit.com',
}, {
  name: 'MailChimp',
  pattern: 'list-manage.com/track',
  homepage: 'http://mailchimp.com',
}, {
  name: 'Postmark',
  pattern: 'cmail1.com/t',
  homepage: 'http://postmarkapp.com',
}, {
  name: 'iContact',
  pattern: 'click.icptrack.com/icp/',
  homepage: 'http://icontact.com',
}, {
  name: 'Infusionsoft',
  pattern: 'infusionsoft.com/app/emailOpened',
  homepage: 'http://infusionsoft.com',
}, {
  name: 'Intercom',
  pattern: 'via.intercom.io/o',
  homepage: 'http://intercom.io',
}, {
  name: 'Mandrill',
  pattern: 'mandrillapp.com/track',
  homepage: 'http://mandrillapp.com',
}, {
  name: 'Hubspot',
  pattern: 't.hsms06.com',
  homepage: 'http://hubspot.com',
}, {
  name: 'RelateIQ',
  pattern: 'app.relateiq.com/t.png',
  homepage: 'http://relateiq.com',
}, {
  name: 'RJ Metrics',
  pattern: 'go.rjmetrics.com',
  homepage: 'http://rjmetrics.com',
}, {
  name: 'Mixpanel',
  pattern: 'api.mixpanel.com/track',
  homepage: 'http://mixpanel.com',
}, {
  name: 'Front App',
  pattern: 'web.frontapp.com/api',
  homepage: 'http://frontapp.com',
}, {
  name: 'Mailtrack.io',
  pattern: 'mailtrack.io/trace',
  homepage: 'http://mailtrack.io',
}, {
  name: 'Salesloft',
  pattern: 'sdr.salesloft.com/email_trackers',
  homepage: 'http://salesloft.com',
}, {
  name: 'Nylas',
  pattern: 'nylas.com/open',
  homepage: 'http://nylas.com/N1',
}]

export function removeTrackingImagesFromBody(body) {
  const spliceRegions = [];
  const regex = RegExpUtils.imageTagRegex();

  // Identify img tags that should be cut
  let result = null;
  while ((result = regex.exec(body)) !== null) {
    for (const item of TrackingBlacklist) {
      if (result[1].indexOf(item.pattern) > 0) {
        spliceRegions.push({start: result.index, end: result.index + result[0].length})
        continue;
      }
    }
  }
  // Remove them all, from the end of the string to the start
  let updated = body;
  spliceRegions.reverse().forEach(({start, end}) => {
    updated = updated.substr(0, start) + updated.substr(end);
  });

  return updated;
}

class TrackingPixelsMessageExtension extends MessageViewExtension {
  static formatMessageBody = ({message}) => {
    if (message.isFromMe()) {
      message.body = removeTrackingImagesFromBody(message.body);
    }
  }
}

class TrackingPixelsComposerExtension extends ComposerExtension {
  static prepareNewDraft = ({draft}) => {
    draft.body = removeTrackingImagesFromBody(draft.body);
  }
}

export function activate() {
  ExtensionRegistry.MessageView.register(TrackingPixelsMessageExtension);
  ExtensionRegistry.Composer.register(TrackingPixelsComposerExtension);
}

export function deactivate() {
  ExtensionRegistry.MessageView.unregister(TrackingPixelsMessageExtension);
  ExtensionRegistry.Composer.unregister(TrackingPixelsComposerExtension);
}
<|endoftext|>


<commit_before>'use strict';

const routes = require('./routes');
const methods = require('./methods');
const { handler } = require('./handler');

const rpc = {
  name: 'graphqlprint',
  title: 'GraphQLPrint',
  routes,
  methods,
  handler,
};

module.exports = rpc;
<commit_msg>Avoid duplication<commit_after>'use strict';

const routes = require('./routes');
const { handler } = require('./handler');
const methods = require('./methods');

const rpc = {
  name: 'graphqlprint',
  title: 'GraphQLPrint',
  routes,
  methods,
  handler,
};

module.exports = rpc;
<|endoftext|>


<commit_before>!( function( factory ) {
  if ( typeof define === "function" && define.amd ) {
    define([ "jquery" ], factory );
  } else {
    var init = factory( jQuery );
    init();
  }
}(function($){

  var tmpl = function(html, data) {
    //var html = document.getElementById(id).innerHTML;

    var code =  "var p = []; with(obj) { " +
      "p.push('" +
      html
        .replace(/[\r\n\t]/g, "")
        // Fix bug like: data-keyword='<%=JSON.stringify(obj)%>'
        // Because ' is key word in this string.
        .replace(/'/g, "\t")
        .replace(/<%=(.*?)%>/g, "'); p.push($1); p.push('")
        .replace(/<%/g, "');")
        .replace(/%>/g, "; p.push('") +
      "');}" +

        // Fix bug
      "return p.join('').replace(/\t/g, \"'\");";
    var fn = new Function('obj', code);
    var html;
    try {
      html = fn(data);
    } catch (e) {
      console.log(e.message);
      window.T = {};
      window.T.code = code
      window.T.fn = fn;
      window.T.data = data;

      html = ""
    }
    return html;
  }

  $.fn.template = function(options){
    var $this = $(this);

    // if data-holder is not set, Add a random div
    var id;
    if ($this.data('holder') === undefined) {
      id = new Date().getTime();
      id = 'holder_' + id;
      $('body').append('

');
    }
    options = $.extend({
      holder: $this.data('holder') === undefined ? '#' + id : $this.data('holder'),
      model: $this.data('model') === undefined ? {} : $this.data('model')
    }, options);

    $(options.holder).html(tmpl($this.html(), options.model));

    return {
      updateBy: function(d) {
        $(options.holder).html(tmpl($this.html(), d));
      },
      appendBy: function(d) {
        $(options.holder).append(tmpl($this.html(), d));
      }
    }
  }

  return $;
}));
<commit_msg>Fix init bug.<commit_after>!( function( factory ) {
  if ( typeof define === "function" && define.amd ) {
    define([ "jquery" ], factory );
  } else {
    var init = factory( jQuery );
    init();
  }
}(function($){

  var tmpl = function(html, data) {
    //var html = document.getElementById(id).innerHTML;

    var code =  "var p = []; with(obj) { " +
      "p.push('" +
      html
        .replace(/[\r\n\t]/g, "")
        // Fix bug like: data-keyword='<%=JSON.stringify(obj)%>'
        // Because ' is key word in this string.
        .replace(/'/g, "\t")
        .replace(/<%=(.*?)%>/g, "'); p.push($1); p.push('")
        .replace(/<%/g, "');")
        .replace(/%>/g, "; p.push('") +
      "');}" +

        // Fix bug
      "return p.join('').replace(/\t/g, \"'\");";
    var fn = new Function('obj', code);

    // try {
    //   html = fn(data);
    // } catch (e) {
    //   console.log(e.message);
      // window.T = {};
      // window.T.code = code
      // window.T.fn = fn;
      // window.T.data = data;

    //   html = ""
    // }
    return fn;
  }

  $.fn.template = function(options){
    var $this = $(this);

    // if data-holder is not set, Add a random div
    var id;
    if ($this.data('holder') === undefined) {
      id = new Date().getTime();
      id = 'holder_' + id;
      $('body').append('

');
    }
    options = $.extend({
      holder: $this.data('holder') === undefined ? '#' + id : $this.data('holder'),
      model: $this.data('model')
    }, options);

    if (options.model !== undefined) {

      try {
        $(options.holder).html(tmpl($this.html())(options.model));
      } catch (e) {
        console.log(e.message)
      }
    }

    return {
      updateBy: function(d) {
        try {
          $(options.holder).html(tmpl($this.html())(d));
        } catch (e) {
          console.log(e.message)
        }
      },
      appendBy: function(d) {
        try {
          $(options.holder).append(tmpl($this.html())(d));
        } catch (e) {
          console.log(e.message)
        }
      }
    }
  }

  return $;
}));
<|endoftext|>