How to use warp10 - 10 common examples

To help you get started, we’ve selected a few warp10 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marko-js / marko-widgets / lib / index.js View on Github external
var state = renderedWidgets.state;
    var config = renderedWidgets.config;

    var result = {
        ids: ids
    };

    // NOTE: Calling warp10.stringifyPrepare(obj) will produce a new object that is safe to serializing using
    //       JSON.stringify(). The deserialized/parsed object will need to be converted to the final object using
    //       warp10.finalize(obj)
    if (!isObjectEmpty(state)) {
        result.state = warp10.stringifyPrepare(state);
    }

    if (!isObjectEmpty(config)) {
        result.config = warp10.stringifyPrepare(config);
    }

    return result;
};
github marko-js / marko-widgets / lib / index.js View on Github external
exports.getRenderedWidgets = exports.getRenderedWidgetIds /* deprecated */ = function(widgetsContext) {
    var renderedWidgets = getRenderedWidgets(widgetsContext);
    var ids = renderedWidgets.ids;
    var state = renderedWidgets.state;
    var config = renderedWidgets.config;

    var result = {
        ids: ids
    };

    // NOTE: Calling warp10.stringifyPrepare(obj) will produce a new object that is safe to serializing using
    //       JSON.stringify(). The deserialized/parsed object will need to be converted to the final object using
    //       warp10.finalize(obj)
    if (!isObjectEmpty(state)) {
        result.state = warp10.stringifyPrepare(state);
    }

    if (!isObjectEmpty(config)) {
        result.config = warp10.stringifyPrepare(config);
    }

    return result;
};
github marko-js / marko-widgets / lib / index.js View on Github external
exports.getInitWidgetsCode = function(widgetsContext) {
    var renderedWidgets = getRenderedWidgets(widgetsContext);
    var ids = renderedWidgets.ids;
    var state = renderedWidgets.state;
    var config = renderedWidgets.config;

    var code = '';

    if (!isObjectEmpty(state)) {
        code += warp10.serialize(
                state,
                WARP10_STATE_SERIALIZATION_OPTIONS) +
                ';\n';
    }

    if (!isObjectEmpty(config)) {
        code += warp10.serialize(
                config,
                WARP10_CONFIG_SERIALIZATION_OPTIONS) +
                ';\n';
    }

    code += '$markoWidgets("' + ids + '");';
    return code;
};
github marko-js / marko-widgets / lib / index.js View on Github external
var renderedWidgets = getRenderedWidgets(widgetsContext);
    var ids = renderedWidgets.ids;
    var state = renderedWidgets.state;
    var config = renderedWidgets.config;

    var code = '';

    if (!isObjectEmpty(state)) {
        code += warp10.serialize(
                state,
                WARP10_STATE_SERIALIZATION_OPTIONS) +
                ';\n';
    }

    if (!isObjectEmpty(config)) {
        code += warp10.serialize(
                config,
                WARP10_CONFIG_SERIALIZATION_OPTIONS) +
                ';\n';
    }

    code += '$markoWidgets("' + ids + '");';
    return code;
};
github marko-js / marko-widgets / lib / index.js View on Github external
}

        var widgetStateDeserializationCode;
        var widgetConfigDeserializationCode;

        if (isObjectEmpty(widgetStateStore)) {
            widgetStateDeserializationCode = '';
        } else {
            widgetStateDeserializationCode = warp10.serialize(widgetStateStore, WARP10_STATE_SERIALIZATION_OPTIONS) +
                    ';\n';
        }

        if (isObjectEmpty(widgetConfigStore)) {
            widgetConfigDeserializationCode = '';
        } else {
            widgetConfigDeserializationCode = warp10.serialize(widgetConfigStore,WARP10_CONFIG_SERIALIZATION_OPTIONS) +
                    ';\n';
        }

        var cspNonce = out.global.cspNonce;
        var nonceAttr = cspNonce ? ' nonce='+JSON.stringify(cspNonce) : '';

        if (immediate) {
            out.write('' +
                widgetStateDeserializationCode +
                widgetConfigDeserializationCode +
                '$markoWidgets("' + ids + '")');
        } else {
            out.write('' +
                widgetStateDeserializationCode +
                widgetConfigDeserializationCode +
                '');
github marko-js / marko-widgets / lib / index.js View on Github external
};

        if (rootWidgetDefs) {
            writeWidgets(rootWidgetDefs);
        } else {
            writeWidgets(rootWidgetDef.children);
            rootWidgetDef.children = [];
        }

        var widgetStateDeserializationCode;
        var widgetConfigDeserializationCode;

        if (isObjectEmpty(widgetStateStore)) {
            widgetStateDeserializationCode = '';
        } else {
            widgetStateDeserializationCode = warp10.serialize(widgetStateStore, WARP10_STATE_SERIALIZATION_OPTIONS) +
                    ';\n';
        }

        if (isObjectEmpty(widgetConfigStore)) {
            widgetConfigDeserializationCode = '';
        } else {
            widgetConfigDeserializationCode = warp10.serialize(widgetConfigStore,WARP10_CONFIG_SERIALIZATION_OPTIONS) +
                    ';\n';
        }

        var cspNonce = out.global.cspNonce;
        var nonceAttr = cspNonce ? ' nonce='+JSON.stringify(cspNonce) : '';

        if (immediate) {
            out.write('' +
                widgetStateDeserializationCode +
github marko-js / marko / src / runtime / components / index.js View on Github external
exports.getRenderedComponents = function(out) {
    var renderedComponents = getRenderedComponents(out, true);
    return warp10.stringifyPrepare(renderedComponents);
};
github marko-js / marko / src / runtime / components / legacy / renderer-legacy.js View on Github external
var getComponentsContext = require("../ComponentsContext")
    .___getComponentsContext;
var componentsUtil = require("../util");
var componentLookup = componentsUtil.___componentLookup;
var registry = require("../registry");
var modernRenderer = require("../renderer");
var resolveComponentKey = modernRenderer.___resolveComponentKey;
var trackAsyncComponents = modernRenderer.___trackAsyncComponents;
var beginComponent = require("../beginComponent");
var endComponent = require("../endComponent");
var w10NOOP = require("warp10/constants").NOOP;

function createRendererFunc(templateRenderFunc, componentProps) {
    var typeName = componentProps.___type;
    //var assignedId = componentProps.id;
    var isSplit = componentProps.___split === true;

    return function renderer(input, out, assignedId, renderingLogic) {
        trackAsyncComponents(out);

        var widgetBody = input.renderBody;
        var widgetState = input.widgetState;
        var widgetConfig = input.widgetConfig;

        var componentsContext = getComponentsContext(out);
        var globalComponentsContext = componentsContext.___globalContext;
github marko-js / marko / src / taglibs / core / include-tag.js View on Github external
var w10NOOP = require("warp10/constants").NOOP;
var RENDER_BODY_TO_JSON = function() {
    return w10NOOP;
};

var FLAG_WILL_RERENDER_IN_BROWSER = 1;
var IS_SERVER = typeof window === "undefined";

function doInclude(input, out, throwError) {
    var target = input._target;
    var arg = input._arg || input;
    var renderBody = (target && target.renderBody) || target;

    if (target) {
        if (target.renderer) {
            return target.renderer(arg, out), true;
        } else if (target.render) {
github marko-js / marko / src / runtime / helpers.js View on Github external
"use strict";
var complain = "MARKO_DEBUG" && require("complain");
var removeDashes = require("../compiler/util/removeDashes");
var ComponentsContext = require("./components/ComponentsContext");
var getComponentsContext = ComponentsContext.___getComponentsContext;
var ComponentDef = require("./components/ComponentDef");
var w10NOOP = require("warp10/constants").NOOP;
var isArray = Array.isArray;
var RENDER_BODY_TO_JSON = function() {
    return w10NOOP;
};
var FLAG_WILL_RERENDER_IN_BROWSER = 1;
var IS_SERVER = typeof window === "undefined";

function isFunction(arg) {
    return typeof arg == "function";
}

function classList(arg, classNames) {
    var len;

    if (arg) {
        if (typeof arg == "string") {

warp10

Transport complex JavaScript objects from the server to the web browser at lightning fast speeds

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis