@softvisio/ext
Version:
ExtJS patches
1,134 lines (1,010 loc) • 318 kB
JavaScript
"use strict";
var _get = function get(object, property, receiver) {
if (object === null) object = Function.prototype;
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var _createClass = (function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})();
var _typeof =
typeof Symbol === "function" && typeof Symbol.iterator === "symbol"
? function (obj) {
return typeof obj;
}
: function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (subClass.__proto__ = superClass);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
} else {
obj[key] = value;
}
return obj;
}
(function (f) {
window.Fashion = f();
return;
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
module.exports = f();
} else if (typeof define === "function" && define.amd) {
define([], f);
} else {
var g;
if (typeof window !== "undefined") {
g = window;
} else if (typeof global !== "undefined") {
g = global;
} else if (typeof self !== "undefined") {
g = self;
} else {
g = this;
}
g.Fashion = f();
}
})(function () {
var define, module, exports;
return (function () {
function r(e, n, t) {
function o(i, f) {
if (!n[i]) {
if (!e[i]) {
var c = "function" == typeof require && require;
if (!f && c) return c(i, !0);
if (u) return u(i, !0);
var a = new Error("Cannot find module '" + i + "'");
throw ((a.code = "MODULE_NOT_FOUND"), a);
}
var p = (n[i] = { exports: {} });
e[i][0].call(
p.exports,
function (r) {
var n = e[i][1][r];
return o(n || r);
},
p,
p.exports,
r,
e,
n,
t
);
}
return n[i].exports;
}
for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
o(t[i]);
}
return o;
}
return r;
})()(
{
1: [
function (require, module, exports) {
var _Fashion$apply;
var Fashion = require("./src/export/Base.js");
var CssVariableManager = require("./src/export/css/CssVariableManager.js"),
css = new CssVariableManager();
Fashion.apply(
Fashion,
((_Fashion$apply = {
css: css,
CssExport: CssVariableManager,
Types: require("./src/export/type/Types.js"),
ValueParser: require("./src/export/parse/ValueParser.js"),
Type: require("./src/export/type/Type.js"),
Bool: require("./src/export/type/Bool.js"),
Literal: require("./src/export/type/Literal.js"),
ParentheticalExpression: require("./src/export/type/ParentheticalExpression.js"),
Text: require("./src/export/type/Text.js"),
Numeric: require("./src/export/type/Numeric.js"),
List: require("./src/export/type/List.js"),
Map: require("./src/export/type/Map.js"),
Color: require("./src/export/type/Color.js"),
ColorRGBA: require("./src/export/type/ColorRGBA.js"),
ColorHSLA: require("./src/export/type/ColorHSLA.js"),
ColorStop: require("./src/export/type/ColorStop.js"),
FunctionCall: require("./src/export/type/FunctionCall.js"),
LinearGradient: require("./src/export/type/LinearGradient.js"),
RadialGradient: require("./src/export/type/RadialGradient.js"),
Statics: require("./src/export/type/Statics.js"),
SourceBuilder: require("./src/export/type/SourceBuilder.js"),
}),
_defineProperty(_Fashion$apply, "Types", require("./src/export/type/Types.js")),
_defineProperty(_Fashion$apply, "TypeVisitor", require("./src/export/type/TypeVisitor.js")),
_defineProperty(_Fashion$apply, "Output", require("./src/export/Output.js")),
_defineProperty(_Fashion$apply, "Runtime", require("./src/export/Runtime.js")),
_Fashion$apply)
);
module.exports = Fashion;
},
{ "./src/export/Base.js": 3, "./src/export/Output.js": 4, "./src/export/Runtime.js": 5, "./src/export/css/CssVariableManager.js": 6, "./src/export/parse/ValueParser.js": 7, "./src/export/type/Bool.js": 8, "./src/export/type/Color.js": 9, "./src/export/type/ColorHSLA.js": 10, "./src/export/type/ColorRGBA.js": 11, "./src/export/type/ColorStop.js": 12, "./src/export/type/FunctionCall.js": 13, "./src/export/type/LinearGradient.js": 14, "./src/export/type/List.js": 15, "./src/export/type/Literal.js": 16, "./src/export/type/Map.js": 17, "./src/export/type/Numeric.js": 18, "./src/export/type/ParentheticalExpression.js": 19, "./src/export/type/RadialGradient.js": 20, "./src/export/type/SourceBuilder.js": 21, "./src/export/type/Statics.js": 22, "./src/export/type/Text.js": 23, "./src/export/type/Type.js": 24, "./src/export/type/TypeVisitor.js": 25, "./src/export/type/Types.js": 26 },
],
2: [
function (require, module, exports) {
"use strict";
function getJsName(name) {
return name.replace(/\-/g, "_").replace(/\//g, "_fs_").replace(/\\/g, "_bs_");
}
var NameConverter = (function () {
function NameConverter() {
_classCallCheck(this, NameConverter);
this.variableNameMap = {};
}
_createClass(NameConverter, [
{
key: "convertName",
value: function convertName(name) {
var map = this.variableNameMap,
converted = map[name];
if (converted === undefined) {
converted = map[name] = getJsName(name);
}
return converted;
},
},
]);
return NameConverter;
})();
var converter = new NameConverter();
module.exports = {
NameConverter: NameConverter,
getJsName: function getJsName(name) {
return converter.convertName(name);
},
};
},
{},
],
3: [
function (require, module, exports) {
/*
* Copyright (c) 2012-2016. Sencha Inc.
*/
"use strict";
var NameConverter = require("./../NameConverter.js");
var debugging = {
trace: false,
};
var Base = function Base(config) {
_classCallCheck(this, Base);
if (config) {
merge(this, config);
}
};
var BaseSet = (function () {
function BaseSet() {
_classCallCheck(this, BaseSet);
}
_createClass(BaseSet, [
{
key: "first",
value: function first() {
return _first(this.items);
},
},
{
key: "last",
value: function last() {
return _last(this.items);
},
},
{
key: "tail",
value: function tail() {
return _tail(this.items);
},
},
]);
return BaseSet;
})();
BaseSet.prototype.items = null;
function _chainFunc() {}
function apply(target, source) {
target = target || {};
if (source) {
for (var name in source) {
target[name] = source[name];
}
}
return target;
}
function merge(destination, object) {
destination = destination || {};
var key, value, sourceKey;
if (object) {
for (key in object) {
value = object[key];
if (value && value.constructor === Object) {
sourceKey = destination[key];
if (sourceKey && sourceKey.constructor === Object) {
merge(sourceKey, value);
} else {
destination[key] = value;
}
} else {
destination[key] = value;
}
}
}
return destination;
}
var chain =
Object.create ||
function (Parent) {
_chainFunc.prototype = Parent;
return new _chainFunc();
};
function createMessage(message, source) {
if (source && source.isFashionScanner) {
message += ": " + source.currentFile + ":" + source.lineNumber;
} else if (source) {
message += ": " + source.file + ":" + source.lineNumber;
}
return message;
}
function isFunction(obj) {
return obj && typeof obj === "function";
}
function trace(message, source) {
if (debugging.trace) {
console.log(createMessage("[DBG] " + message, source));
}
}
function debug(message, source) {
console.log(createMessage("[DBG] " + message, source));
}
function log(message, source) {
console.log(createMessage("[LOG] " + message, source));
}
function info(message, source) {
console.log(createMessage("[INF] " + message, source));
}
function warn(message, source) {
console.log(createMessage("[WRN] " + message, source));
}
function error(message, source) {
console.log(createMessage("[ERR] " + message, source));
}
function raise(message, extra) {
if (Fashion.inspect) {
debugger;
}
if (typeof message !== "string") {
extra = message;
message = extra.message;
delete extra.message;
}
var error = new Error(message);
error.$isFashionError = true;
throw apply(error, extra);
}
function raiseAt(message, source, stack) {
var extra;
if (source) {
message = createMessage(message, source);
if (source.isFashionScanner) {
extra = {
file: source.currentFile,
lineNumber: source.lineNumber,
};
} else {
extra = {
node: source,
lineNumber: source.lineNumber,
file: source.file,
};
}
}
if (stack) {
if (!extra) {
extra = {};
}
extra.fashionStack = stack;
}
raise(message, extra);
}
function filter(array, func) {
var result = [];
for (var i = 0; i < array.length; i++) {
var item = array[i];
if (func(item, i)) {
result.push(item);
}
}
return result;
}
function convert(array, func) {
var converted = [];
for (var i = 0; i < array.length; i++) {
converted.push(func(array[i]));
}
return converted;
}
function _first(array) {
return array.length && array[0];
}
function _last(array) {
return array.length && array[array.length - 1];
}
function _tail(array) {
if (array.length > 2) {
return array.slice(1);
}
return [];
}
function getAllKeys(obj, stop) {
var keys = [],
map = {},
i,
key,
n,
names;
for (; obj && obj !== stop; obj = Object.getPrototypeOf(obj)) {
names = Object.getOwnPropertyNames(obj);
for (i = 0, n = names.length; i < n; ++i) {
key = names[i];
if (!map[key]) {
map[key] = true;
keys.push(key);
}
}
}
return keys;
}
function mixin(target, bases) {
if (!Array.isArray(bases)) {
bases = Array.prototype.slice.call(arguments, 1);
}
var proto = target.prototype;
for (var b = 0; b < bases.length; b++) {
var base = bases[b],
baseProto = base.prototype;
getAllKeys(baseProto, Base.prototype).forEach(function (name) {
if (name in baseProto) {
if (!(name in proto)) {
proto[name] = baseProto[name];
}
}
});
}
}
function flatten(array, level, output) {
output = output || [];
level = typeof level === "undefined" ? 1000 : level;
for (var i = 0; i < array.length; i++) {
var item = array[i];
if (Array.isArray(item) && level) {
flatten(item, level - 1, output);
} else {
output.push(item);
}
}
return output;
}
module.exports = {
EmptyArray: [],
getJsName: NameConverter.getJsName,
chain: chain,
Base: Base,
BaseSet: BaseSet,
apply: apply,
merge: merge,
createMessage: createMessage,
isFunction: isFunction,
debugging: debugging,
trace: trace,
debug: debug,
log: log,
info: info,
warn: warn,
error: error,
raise: raise,
raiseAt: raiseAt,
filter: filter,
convert: convert,
first: _first,
last: _last,
tail: _tail,
mixin: mixin,
flatten: flatten,
};
},
{ "./../NameConverter.js": 2 },
],
4: [
function (require, module, exports) {
/*
* Copyright (c) 2012-2016. Sencha Inc.
*/
"use strict";
var Fashion = require("./Base.js"),
Base = Fashion.Base;
var Output = (function (_Base) {
_inherits(Output, _Base);
function Output() {
_classCallCheck(this, Output);
var _this = _possibleConstructorReturn(this, (Output.__proto__ || Object.getPrototypeOf(Output)).call(this));
_this.output = "";
return _this;
}
_createClass(Output, [
{
key: "space",
value: function space() {
this.add(" ");
},
},
{
key: "add",
value: function add(text) {
this.output += text;
},
},
{
key: "addComment",
value: function addComment(text) {
this.output += text;
},
},
{
key: "indent",
value: function indent() {
this.indentation += this.indentstr;
},
},
{
key: "unindent",
value: function unindent() {
this.indentation = this.indentation.substr(this.indentstr.length);
},
},
{
key: "addln",
value: function addln(ln) {
this.output += "\n" + this.indentation + (ln || "");
},
},
{
key: "addCommentLn",
value: function addCommentLn(ln) {
if (ln && ln.indexOf("//") === 0) {
return;
}
this.addln(ln);
},
},
{
key: "get",
value: function get() {
return this.output;
},
},
{
key: "indentln",
value: function indentln(ln) {
this.addln(ln);
this.indent();
},
},
{
key: "unindentln",
value: function unindentln(ln) {
this.unindent();
this.addln(ln);
},
},
{
key: "reset",
value: function reset() {
this.indentation = "";
this.output = "";
},
},
]);
return Output;
})(Base);
Fashion.apply(Output.prototype, {
indentation: "",
output: "",
isCompressed: false,
indentstr: " ",
splitThreshold: 1000000,
selectorCount: 0,
});
module.exports = Output;
},
{ "./Base.js": 3 },
],
5: [
function (require, module, exports) {
"use strict";
var Fashion = require("./Base.js"),
Base = Fashion.Base;
var Type = require("./type/Type.js");
var List = require("./type/List.js");
var Bool = require("./type/Bool.js");
var Color = require("./type/Color.js");
var ColorRGBA = require("./type/ColorRGBA.js");
var Text = require("./type/Text.js");
var Literal = require("./type/Literal.js");
var Statics = require("./type/Statics.js");
var TypeVisitor = require("./type/TypeVisitor.js");
var Types = require("./type/Types.js");
var Scope = (function () {
function Scope(prev) {
_classCallCheck(this, Scope);
this.prev = prev;
this.map = {};
this.sourceInfo = null;
}
_createClass(Scope, [
{
key: "get",
value: function get(name) {
var map = this.map,
prev = this,
value;
while (map) {
value = map[name];
if (value) {
return value;
}
prev = prev.prev;
map = prev && prev.map;
}
return value;
},
},
{
key: "has",
value: function has(name) {
//return name in this.map;
var map = this.map,
prev = this;
while (map) {
if (name in map) {
return true;
}
prev = prev.prev;
map = prev && prev.map;
}
return false;
},
},
{
key: "put",
value: function put(name, value) {
this.map[name] = value;
return value;
},
},
{
key: "addEntries",
value: function addEntries(names) {
if (this.prev) {
this.prev.addEntries(names);
}
for (var name in this.map) {
names[name] = this.map[name];
}
},
},
{
key: "getEntries",
value: function getEntries(entries) {
entries = entries || {};
this.addEntries(entries);
return entries;
},
},
{
key: "getSourceInfo",
value: function getSourceInfo() {
return this.sourceInfo;
},
},
{
key: "getCallStack",
value: function getCallStack(stack) {
stack = stack || [];
if (this.sourceInfo) {
stack.push(this.sourceInfo);
}
if (this.prev) {
this.prev.getCallStack(stack);
}
return stack;
},
},
]);
return Scope;
})();
Fashion.apply(Scope.prototype, {
$isScope: true,
map: undefined,
prev: undefined,
// placeholder used to track what to reset the _currentScope to,
resetScope: undefined,
});
var Runtime = (function (_Base2) {
_inherits(Runtime, _Base2);
function Runtime(config) {
_classCallCheck(this, Runtime);
var _this2 = _possibleConstructorReturn(this, (Runtime.__proto__ || Object.getPrototypeOf(Runtime)).call(this, config));
var me = _this2;
me.mixins = {};
me.functions = {};
me.processors = [];
me.registered = {
runtime: me,
box: Statics.boxType,
unbox: Statics.unboxType,
isArray: function isArray(array) {
return Array.isArray(array);
},
getRuntime: function getRuntime() {
return this.runtime;
},
handleArgs: function handleArgs(args, keys) {
var scope = {},
index = 0,
key;
for (var a = 0; a < args.length; a++) {
var arg = args[a];
if (arg === undefined) {
continue;
}
// Named arguments
if (arg === true || arg === false) {
scope[keys[index]] = arg;
index++;
} else if (arg.type === undefined) {
for (key in arg) {
scope[key.replace(/^\$/, "")] = arg[key];
}
}
// Required arguments
else {
key = keys[index];
if (key instanceof Array) {
key = key[0];
scope[key] = scope[key] || new List();
scope[key].add(arg);
} else {
scope[key] = arg;
index++;
}
}
}
return scope;
},
sliceArgs: function sliceArgs(args, start, end) {
return this.getRuntime().sliceArgs(args, start, end).items;
},
tailArgs: function tailArgs(start, args) {
var tail = Array.prototype.slice.call(args, start);
if (tail.length == 1 && this.isArray(tail)) {
tail = tail[0];
}
return tail;
},
};
return _this2;
}
_createClass(Runtime, [
{
key: "bool",
value: function bool(value) {
return new Bool(value);
},
},
{
key: "color",
value: function color(name) {
var rgb = Color.map[name],
color = new ColorRGBA(rgb[0], rgb[1], rgb[2], rgb[3]);
color.stringified = name;
return color;
},
},
{
key: "quote",
value: function quote(value) {
if (value.type === "string") {
return value;
}
return new Text(value.toString());
},
},
{
key: "unquote",
value: function unquote(value) {
if (value.$isFashionType) {
return value.unquote();
}
return new Literal(value.toString());
},
},
{
key: "not",
value: function not(expression) {
return this.box(this.unbox(expression) == false);
},
},
{
key: "operate",
value: function operate(operation, left, right) {
if (left == null || left.$isFashionNull) {
if (operation != "==" && operation != "!=") {
return Literal.Null;
}
}
if (right == null || right.$isFashionNull) {
if (operation != "==" && operation != "!=") {
return Literal.Null;
}
}
return left.operate(operation, right);
},
},
{
key: "reset",
value: function reset() {
this._currentScope = null;
this._currentCallStackScope = this.createCallStackScope();
this._globalScope = this.createScope();
this._dynamics = {};
},
},
{
key: "run",
value: function run(code, metadata) {
this.load(code);
this.compile(code);
return this.execute(metadata);
},
},
{
key: "createTypesBlock",
value: function createTypesBlock(types) {
types = types || this.types;
var keys = Object.getOwnPropertyNames(types),
buff = [],
name;
for (var i = 0; i < keys.length; i++) {
name = keys[i];
buff.push(name + " = Types." + name);
buff.push("__" + name + " = " + name);
}
if (buff.length === 0) {
return "";
}
return "var " + buff.join(",\n ") + ";\n";
},
},
{
key: "createMethodBlock",
value: function createMethodBlock(proto) {
proto = proto || this.constructor.prototype;
var buff = [],
keys,
name;
while (proto) {
keys = Object.getOwnPropertyNames(proto);
for (var i = 0; i < keys.length; i++) {
name = keys[i];
if (typeof proto[name] === "function") {
buff.push("__rt_" + name + " = __rt." + name + ".bind(__rt)");
}
}
proto = Object.getPrototypeOf(proto);
}
if (buff.length === 0) {
return "";
}
return "var " + buff.join(",\n ") + ";\n";
},
},
{
key: "createPropertyBlock",
value: function createPropertyBlock() {
var keys = Object.getOwnPropertyNames(this),
buff = [],
name;
for (var i = 0; i < keys.length; i++) {
name = keys[i];
buff.push("__rt_" + name + " = __rt." + name);
}
if (buff.length === 0) {
return "";
}
return "var " + buff.join(",\n ") + ";\n";
},
},
{
key: "createPrefixedFunctionBody",
value: function createPrefixedFunctionBody(code) {
code = this.createTypesBlock() + this.createMethodBlock() + this.createPropertyBlock() + code;
return code;
},
},
{
key: "createWrappedFn",
value: function createWrappedFn(code) {
return new Function("Types", "__rt", "__gs", "__udf", "__dyn", this.createPrefixedFunctionBody(code));
},
},
{
key: "callWrappedFn",
value: function callWrappedFn(fn, dynamics) {
return fn(Fashion, this, this._globalScope, undefined, dynamics || {});
},
},
{
key: "compile",
value: function compile(code) {
var me = this,
theFn;
//code = '"use strict";\n' + code;
this.code = code;
new Function();
theFn = this.createWrappedFn(code);
this.fn = function (rt, overrides, dyn) {
var runtime = rt || me,
dynamics = dyn || {};
runtime.reset();
if (overrides) {
if (overrides.$isScope) {
runtime._globalScope = overrides;
} else {
runtime._globalScope.map = overrides;
}
}
if (dyn) {
runtime._dynamics = dyn;
}
runtime._currentScope = runtime._globalScope;
runtime._scopeStack = [runtime._currentScope];
try {
theFn(me.types, runtime, runtime._globalScope, undefined, dynamics);
} catch (err) {
Fashion.raiseAt(err.message || err, null, runtime.getCallStack());
}
return runtime._globalScope;
};
return this.fn;
},
},
{
key: "execute",
value: function execute(metadata) {
return this.fn(this, metadata);
},
},
{
key: "load",
value: function load(code) {
this.code = code;
return this;
},
},
{
key: "registerProcessor",
value: function registerProcessor(proc) {
this.processors.push(new TypeVisitor(proc));
},
},
{
key: "register",
value: function register(methods) {
if (methods["dynamic"]) {
Fashion.error('Cannot register javascript function named "dynamic"');
delete methods["dynamic"];
}
if (methods["require"]) {
Fashion.error('Cannot register javascript function named "require"');
delete methods["require"];
}
Fashion.apply(this.registered, methods);
},
},
{
key: "isRegistered",
value: function isRegistered(name) {
name = this.reserved[name] ? "__" + name : name;
return !!this.registered[name];
},
},
{
key: "getGlobalScope",
value: function getGlobalScope() {
return this._globalScope;
},
},
{
key: "getCurrentScope",
value: function getCurrentScope() {
return this._currentScope;
},
},
{
key: "getRegisteredFunctions",
value: function getRegisteredFunctions() {
return this.registered;
},
},
{
key: "getFunctions",
value: function getFunctions() {
return this.functions;
},
},
{
key: "getMixins",
value: function getMixins() {
return this.mixins;
},
},
{
key: "createScope",
value: function createScope(scope) {
var currScope = scope || this._currentScope,
newScope = new Scope(currScope);
return this.pushScope(newScope);
},
},
{
key: "pushScope",
value: function pushScope(scope) {
scope.resetScope = this._currentScope;
this._currentScope = scope;
return scope;