mobiledoc-dom-renderer
Advanced tools
Comparing version 0.1.16 to 0.1.17
;(function() { | ||
var define, requireModule, require, requirejs; | ||
(function() { | ||
'use strict'; | ||
@@ -10,3 +10,3 @@ var _isArray; | ||
_isArray = function (x) { | ||
return Object.prototype.toString.call(x) === "[object Array]"; | ||
return Object.prototype.toString.call(x) === '[object Array]'; | ||
}; | ||
@@ -20,15 +20,9 @@ } else { | ||
var FAILED = false; | ||
var LOADED = true; | ||
var uuid = 0; | ||
function tryFinally(tryable, finalizer) { | ||
try { | ||
return tryable(); | ||
} finally { | ||
finalizer(); | ||
} | ||
} | ||
function unsupportedModule(length) { | ||
throw new Error("an unsupported module was defined, expected `define(name, deps, module)` instead got: `" + length + "` arguments to define`"); | ||
throw new Error('an unsupported module was defined, expected `define(name, deps, module)` instead got: `' + | ||
length + '` arguments to define`'); | ||
} | ||
@@ -38,13 +32,66 @@ | ||
function Module(name, deps, callback, exports) { | ||
this.id = uuid++; | ||
this.name = name; | ||
this.deps = !deps.length && callback.length ? defaultDeps : deps; | ||
this.exports = exports || { }; | ||
this.callback = callback; | ||
this.state = undefined; | ||
function Module(name, deps, callback) { | ||
this.id = uuid++; | ||
this.name = name; | ||
this.deps = !deps.length && callback.length ? defaultDeps : deps; | ||
this.module = { exports: {} }; | ||
this.callback = callback; | ||
this.state = undefined; | ||
this._require = undefined; | ||
this.finalized = false; | ||
this.hasExportsAsDep = false; | ||
} | ||
Module.prototype.makeDefaultExport = function() { | ||
var exports = this.module.exports; | ||
if (exports !== null && | ||
(typeof exports === 'object' || typeof exports === 'function') && | ||
exports['default'] === undefined) { | ||
exports['default'] = exports; | ||
} | ||
}; | ||
Module.prototype.exports = function(reifiedDeps) { | ||
if (this.finalized) { | ||
return this.module.exports; | ||
} else { | ||
var result = this.callback.apply(this, reifiedDeps); | ||
if (!(this.hasExportsAsDep && result === undefined)) { | ||
this.module.exports = result; | ||
} | ||
this.makeDefaultExport(); | ||
this.finalized = true; | ||
return this.module.exports; | ||
} | ||
}; | ||
Module.prototype.unsee = function() { | ||
this.finalized = false; | ||
this.state = undefined; | ||
this.module = { exports: {}}; | ||
}; | ||
Module.prototype.reify = function() { | ||
var deps = this.deps; | ||
var length = deps.length; | ||
var reified = new Array(length); | ||
var dep; | ||
for (var i = 0, l = length; i < l; i++) { | ||
dep = deps[i]; | ||
if (dep === 'exports') { | ||
this.hasExportsAsDep = true; | ||
reified[i] = this.module.exports; | ||
} else if (dep === 'require') { | ||
reified[i] = this.makeRequire(); | ||
} else if (dep === 'module') { | ||
reified[i] = this.module; | ||
} else { | ||
reified[i] = findModule(resolve(dep, this.name), this.name).module.exports; | ||
} | ||
} | ||
return reified; | ||
}; | ||
Module.prototype.makeRequire = function() { | ||
@@ -56,4 +103,11 @@ var name = this.name; | ||
}); | ||
} | ||
}; | ||
Module.prototype.build = function() { | ||
if (this.state === FAILED) { return; } | ||
this.state = FAILED; | ||
this.exports(this.reify()); | ||
this.state = LOADED; | ||
}; | ||
define = function(name, deps, callback) { | ||
@@ -85,88 +139,24 @@ if (arguments.length < 2) { | ||
function reify(mod, name, seen) { | ||
var deps = mod.deps; | ||
var length = deps.length; | ||
var reified = new Array(length); | ||
var dep; | ||
// TODO: new Module | ||
// TODO: seen refactor | ||
var module = { }; | ||
for (var i = 0, l = length; i < l; i++) { | ||
dep = deps[i]; | ||
if (dep === 'exports') { | ||
module.exports = reified[i] = seen; | ||
} else if (dep === 'require') { | ||
reified[i] = mod.makeRequire(); | ||
} else if (dep === 'module') { | ||
mod.exports = seen; | ||
module = reified[i] = mod; | ||
} else { | ||
reified[i] = requireFrom(resolve(dep, name), name); | ||
} | ||
} | ||
return { | ||
deps: reified, | ||
module: module | ||
}; | ||
function missingModule(name, referrer) { | ||
throw new Error('Could not find module `' + name + '` imported from `' + referrer + '`'); | ||
} | ||
function requireFrom(name, origin) { | ||
var mod = registry[name]; | ||
if (!mod) { | ||
throw new Error('Could not find module `' + name + '` imported from `' + origin + '`'); | ||
} | ||
return require(name); | ||
} | ||
requirejs = require = requireModule = function(name) { | ||
return findModule(name, '(require)').module.exports; | ||
}; | ||
function missingModule(name) { | ||
throw new Error('Could not find module ' + name); | ||
} | ||
requirejs = require = requireModule = function(name) { | ||
function findModule(name, referrer) { | ||
var mod = registry[name]; | ||
if (mod && mod.callback instanceof Alias) { | ||
mod = registry[mod.callback.name]; | ||
while (mod && mod.callback instanceof Alias) { | ||
name = mod.callback.name; | ||
mod = registry[name]; | ||
} | ||
if (!mod) { missingModule(name); } | ||
if (!mod) { missingModule(name, referrer); } | ||
if (mod.state !== FAILED && | ||
seen.hasOwnProperty(name)) { | ||
return seen[name]; | ||
} | ||
mod.build(); | ||
return mod; | ||
} | ||
var reified; | ||
var module; | ||
var loaded = false; | ||
seen[name] = { }; // placeholder for run-time cycles | ||
tryFinally(function() { | ||
reified = reify(mod, name, seen[name]); | ||
module = mod.callback.apply(this, reified.deps); | ||
loaded = true; | ||
}, function() { | ||
if (!loaded) { | ||
mod.state = FAILED; | ||
} | ||
}); | ||
var obj; | ||
if (module === undefined && reified.module.exports) { | ||
obj = reified.module.exports; | ||
} else { | ||
obj = seen[name] = module; | ||
} | ||
if (obj !== null && | ||
(typeof obj === 'object' || typeof obj === 'function') && | ||
obj['default'] === undefined) { | ||
obj['default'] = obj; | ||
} | ||
return (seen[name] = obj); | ||
}; | ||
function resolve(child, name) { | ||
@@ -197,3 +187,3 @@ if (child.charAt(0) !== '.') { return child; } | ||
requirejs.unsee = function(moduleName) { | ||
delete seen[moduleName]; | ||
findModule(moduleName, '(unsee)').unsee(); | ||
}; | ||
@@ -203,3 +193,3 @@ | ||
requirejs.entries = requirejs._eak_seen = registry = {}; | ||
seen = state = {}; | ||
seen = {}; | ||
}; | ||
@@ -481,2 +471,3 @@ })(); | ||
require("mobiledoc-dom-renderer")["registerGlobal"](window, document); | ||
})();//# sourceMappingURL=mobiledoc-dom-renderer.map | ||
})(); | ||
//# sourceMappingURL=mobiledoc-dom-renderer.map |
var define, requireModule, require, requirejs; | ||
(function() { | ||
'use strict'; | ||
@@ -8,3 +9,3 @@ var _isArray; | ||
_isArray = function (x) { | ||
return Object.prototype.toString.call(x) === "[object Array]"; | ||
return Object.prototype.toString.call(x) === '[object Array]'; | ||
}; | ||
@@ -18,15 +19,9 @@ } else { | ||
var FAILED = false; | ||
var LOADED = true; | ||
var uuid = 0; | ||
function tryFinally(tryable, finalizer) { | ||
try { | ||
return tryable(); | ||
} finally { | ||
finalizer(); | ||
} | ||
} | ||
function unsupportedModule(length) { | ||
throw new Error("an unsupported module was defined, expected `define(name, deps, module)` instead got: `" + length + "` arguments to define`"); | ||
throw new Error('an unsupported module was defined, expected `define(name, deps, module)` instead got: `' + | ||
length + '` arguments to define`'); | ||
} | ||
@@ -36,13 +31,66 @@ | ||
function Module(name, deps, callback, exports) { | ||
this.id = uuid++; | ||
this.name = name; | ||
this.deps = !deps.length && callback.length ? defaultDeps : deps; | ||
this.exports = exports || { }; | ||
this.callback = callback; | ||
this.state = undefined; | ||
function Module(name, deps, callback) { | ||
this.id = uuid++; | ||
this.name = name; | ||
this.deps = !deps.length && callback.length ? defaultDeps : deps; | ||
this.module = { exports: {} }; | ||
this.callback = callback; | ||
this.state = undefined; | ||
this._require = undefined; | ||
this.finalized = false; | ||
this.hasExportsAsDep = false; | ||
} | ||
Module.prototype.makeDefaultExport = function() { | ||
var exports = this.module.exports; | ||
if (exports !== null && | ||
(typeof exports === 'object' || typeof exports === 'function') && | ||
exports['default'] === undefined) { | ||
exports['default'] = exports; | ||
} | ||
}; | ||
Module.prototype.exports = function(reifiedDeps) { | ||
if (this.finalized) { | ||
return this.module.exports; | ||
} else { | ||
var result = this.callback.apply(this, reifiedDeps); | ||
if (!(this.hasExportsAsDep && result === undefined)) { | ||
this.module.exports = result; | ||
} | ||
this.makeDefaultExport(); | ||
this.finalized = true; | ||
return this.module.exports; | ||
} | ||
}; | ||
Module.prototype.unsee = function() { | ||
this.finalized = false; | ||
this.state = undefined; | ||
this.module = { exports: {}}; | ||
}; | ||
Module.prototype.reify = function() { | ||
var deps = this.deps; | ||
var length = deps.length; | ||
var reified = new Array(length); | ||
var dep; | ||
for (var i = 0, l = length; i < l; i++) { | ||
dep = deps[i]; | ||
if (dep === 'exports') { | ||
this.hasExportsAsDep = true; | ||
reified[i] = this.module.exports; | ||
} else if (dep === 'require') { | ||
reified[i] = this.makeRequire(); | ||
} else if (dep === 'module') { | ||
reified[i] = this.module; | ||
} else { | ||
reified[i] = findModule(resolve(dep, this.name), this.name).module.exports; | ||
} | ||
} | ||
return reified; | ||
}; | ||
Module.prototype.makeRequire = function() { | ||
@@ -54,4 +102,11 @@ var name = this.name; | ||
}); | ||
} | ||
}; | ||
Module.prototype.build = function() { | ||
if (this.state === FAILED) { return; } | ||
this.state = FAILED; | ||
this.exports(this.reify()); | ||
this.state = LOADED; | ||
}; | ||
define = function(name, deps, callback) { | ||
@@ -83,88 +138,24 @@ if (arguments.length < 2) { | ||
function reify(mod, name, seen) { | ||
var deps = mod.deps; | ||
var length = deps.length; | ||
var reified = new Array(length); | ||
var dep; | ||
// TODO: new Module | ||
// TODO: seen refactor | ||
var module = { }; | ||
for (var i = 0, l = length; i < l; i++) { | ||
dep = deps[i]; | ||
if (dep === 'exports') { | ||
module.exports = reified[i] = seen; | ||
} else if (dep === 'require') { | ||
reified[i] = mod.makeRequire(); | ||
} else if (dep === 'module') { | ||
mod.exports = seen; | ||
module = reified[i] = mod; | ||
} else { | ||
reified[i] = requireFrom(resolve(dep, name), name); | ||
} | ||
} | ||
return { | ||
deps: reified, | ||
module: module | ||
}; | ||
function missingModule(name, referrer) { | ||
throw new Error('Could not find module `' + name + '` imported from `' + referrer + '`'); | ||
} | ||
function requireFrom(name, origin) { | ||
var mod = registry[name]; | ||
if (!mod) { | ||
throw new Error('Could not find module `' + name + '` imported from `' + origin + '`'); | ||
} | ||
return require(name); | ||
} | ||
requirejs = require = requireModule = function(name) { | ||
return findModule(name, '(require)').module.exports; | ||
}; | ||
function missingModule(name) { | ||
throw new Error('Could not find module ' + name); | ||
} | ||
requirejs = require = requireModule = function(name) { | ||
function findModule(name, referrer) { | ||
var mod = registry[name]; | ||
if (mod && mod.callback instanceof Alias) { | ||
mod = registry[mod.callback.name]; | ||
while (mod && mod.callback instanceof Alias) { | ||
name = mod.callback.name; | ||
mod = registry[name]; | ||
} | ||
if (!mod) { missingModule(name); } | ||
if (!mod) { missingModule(name, referrer); } | ||
if (mod.state !== FAILED && | ||
seen.hasOwnProperty(name)) { | ||
return seen[name]; | ||
} | ||
mod.build(); | ||
return mod; | ||
} | ||
var reified; | ||
var module; | ||
var loaded = false; | ||
seen[name] = { }; // placeholder for run-time cycles | ||
tryFinally(function() { | ||
reified = reify(mod, name, seen[name]); | ||
module = mod.callback.apply(this, reified.deps); | ||
loaded = true; | ||
}, function() { | ||
if (!loaded) { | ||
mod.state = FAILED; | ||
} | ||
}); | ||
var obj; | ||
if (module === undefined && reified.module.exports) { | ||
obj = reified.module.exports; | ||
} else { | ||
obj = seen[name] = module; | ||
} | ||
if (obj !== null && | ||
(typeof obj === 'object' || typeof obj === 'function') && | ||
obj['default'] === undefined) { | ||
obj['default'] = obj; | ||
} | ||
return (seen[name] = obj); | ||
}; | ||
function resolve(child, name) { | ||
@@ -195,3 +186,3 @@ if (child.charAt(0) !== '.') { return child; } | ||
requirejs.unsee = function(moduleName) { | ||
delete seen[moduleName]; | ||
findModule(moduleName, '(unsee)').unsee(); | ||
}; | ||
@@ -201,4 +192,4 @@ | ||
requirejs.entries = requirejs._eak_seen = registry = {}; | ||
seen = state = {}; | ||
seen = {}; | ||
}; | ||
})(); |
{ | ||
"name": "mobiledoc-dom-renderer", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"description": "Renders Mobiledoc input to DOM output", | ||
@@ -14,4 +14,4 @@ "scripts": { | ||
"keywords": [ | ||
"ember-addon", | ||
"mobiledoc", | ||
"mobiledoc-renderer", | ||
"content-kit" | ||
@@ -37,9 +37,3 @@ ], | ||
}, | ||
"dependencies": { | ||
"broccoli-funnel": "^0.2.8" | ||
}, | ||
"main": "dist/commonjs/mobiledoc-dom-renderer/index.js", | ||
"ember-addon": { | ||
"main": "index.js" | ||
} | ||
"main": "dist/commonjs/mobiledoc-dom-renderer/index.js" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
201108
0
5155
3
21
- Removedbroccoli-funnel@^0.2.8
- Removedarray-equal@1.0.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedblank-object@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbroccoli-funnel@0.2.15(transitive)
- Removedbroccoli-plugin@1.3.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removedensure-posix-path@1.1.1(transitive)
- Removedfast-ordered-set@1.0.3(transitive)
- Removedfs-tree-diff@0.3.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedmatcher-collection@1.1.2(transitive)
- Removedminimatch@2.0.103.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedmktemp@0.4.0(transitive)
- Removedms@2.0.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-posix@1.0.0(transitive)
- Removedpromise-map-series@0.2.3(transitive)
- Removedquick-temp@0.1.8(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedrsvp@3.6.2(transitive)
- Removedsprintf-js@1.1.3(transitive)
- Removedsymlink-or-copy@1.3.1(transitive)
- Removedunderscore.string@3.3.6(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwalk-sync@0.2.7(transitive)
- Removedwrappy@1.0.2(transitive)