Sequexxer Manual

What does it do?

Sequexxer compiles .dna files into a JavaScript strand (i.e. it Sequexxes dna)

Queries

import

Imports a .dna file from the directory specified, where the full path looked at is the import path specified in the configuration + the directory specified in the import statement

USAGE: @import <filename> from <directory>@

e.g. @import homepage from dna@

retrieve

retrieves data passed in via the configuration method

USAGE: @retrieve <key>@

e.g. @retrieve products@

gets { product: <data$gt; }
params

sets the params passed into a sequencer bundle e.g. window.bundle[x] = function() { contents of your dna file };

USAGE: @params <argument 0> ... <argument n>@

e.g. @params input output@ yields -> window.bundle[x] = function(input, output) { contents of your dna file };

Step 1. Configuration

var data = {
    key1: "word"
}

require("sequexxer").config({
    "data": data,
    "import paths": [
        require("paths")["assets"] + "/dna/",
        require("paths")["assets"] + "/other-dna/"
    ]
});

Step 2. First Request

require("sequexxer")["get package 1"]({
    //- required
    "query": "import entry_point/first_page",

    //- optional
    "launch params": ["start"]
}, function(strand) {
    // strand (of javascript) to be sent to a web browser, where first

    response.write("<script>" + strand + "<script>");
});

Step 3. Subsequent Requests

require("sequexxer")["get package 2+"]({
    //- required
    "query": "import entry_point/second_page",
    "manifest": manifest, // passed in via post request, see next section (send manifest snippet)

    //- optional
    "launch params": ["asdfasdfasdf", "asdfasdfasdf"]
}, function(strand) {
    // the self starting strand (of javascript) to be sent to a web browser

    response.write(strand);
    response.end();
});
    

Send Manifest Snippet


function sequencerXHRRequest(options) {
    // requiered parameter
    var url = options.url;
    var data = options.data || null;

    var update_history = true;
    if (options.hasOwnProperty('update_history')) {
        update_history = options.update_history
    }
    if (update_history) {
        window.history.pushState("object or string", "", url);
    }

    var request = new XMLHttpRequest();
    var manifest = window["manifest"];

    /*
                                                 _                     _ _
      _ __ ___  ___ _ __   ___  _ __  ___  ___  | |__   __ _ _ __   __| | | ___ _ __
     | '__/ _ \/ __| '_ \ / _ \| '_ \/ __|/ _ \ | '_ \ / _` | '_ \ / _` | |/ _ \ '__|
     | | |  __/\__ \ |_) | (_) | | | \__ \  __/ | | | | (_| | | | | (_| | |  __/ |
     |_|  \___||___/ .__/ \___/|_| |_|___/\___| |_| |_|\__,_|_| |_|\__,_|_|\___|_|
                   |_|
     */
    request.onreadystatechange = function() {
        if (request.readyState == 4 && request.status == 200) {
            var response = request.responseText;

            var scriptStart;
            var launch;
            (function() {
                var number = "";

                if (response.substring(0,1) === "*") {
                    for (var i = 1; i < response.length; i++) {
                        var char = response.substring(i,i+1);

                        if (char === "*") {
                            if (number !== -1) {
                                launch = parseInt(number);
                                scriptStart = i + 1;
                                return;
                            }
                            else {
                                console.error("launch number not provided");
                            }
                        }
                        else {
                            number = number + char;
                        }
                    }
                }
                else {
                    console.error("launch not found");
                }
            })();

            var js = response.substring(scriptStart);

            if (js.length > 0) {
                var script = document.createElement("script");
                script.text = js;
                document.getElementById("sequences").appendChild(script);
            }

            window.history.sequence.push({
                url: url,
                data: data
            })

            window.bundle[launch](data);
        }
    };


    /*
                                     _
      _ __ ___  __ _ _   _  ___  ___| |_
     | '__/ _ \/ _` | | | |/ _ \/ __| __|
     | | |  __/ (_| | |_| |  __/\__ \ |_
     |_|  \___|\__, |\__,_|\___||___/\__|
                  |_|

     */

    request.open("POST", url, true);
    request.send(JSON.stringify(manifest));
};

return sequencerXHRRequest;