mobiledoc-text-renderer
Advanced tools
Comparing version 0.3.2 to 0.4.0-beta
@@ -7,4 +7,2 @@ ;(function() { | ||
var heimdall = global.heimdall; | ||
function dict() { | ||
@@ -26,5 +24,5 @@ var obj = Object.create(null); | ||
requirejs = require = requireModule = function (name) { | ||
requirejs = require = requireModule = function (id) { | ||
var pending = []; | ||
var mod = findModule(name, '(require)', pending); | ||
var mod = findModule(id, '(require)', pending); | ||
@@ -52,14 +50,7 @@ for (var i = pending.length - 1; i >= 0; i--) { | ||
} | ||
} | ||
}, | ||
// Option to enable or disable the generation of default exports | ||
makeDefaultExport: true | ||
}; | ||
var _isArray; | ||
if (!Array.isArray) { | ||
_isArray = function (x) { | ||
return Object.prototype.toString.call(x) === '[object Array]'; | ||
}; | ||
} else { | ||
_isArray = Array.isArray; | ||
} | ||
var registry = dict(); | ||
@@ -71,3 +62,3 @@ var seen = dict(); | ||
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(id, deps, module)` instead got: `' + length + '` arguments to define`'); | ||
} | ||
@@ -77,5 +68,5 @@ | ||
function Module(name, deps, callback, alias) { | ||
this.id = uuid++; | ||
this.name = name; | ||
function Module(id, deps, callback, alias) { | ||
this.uuid = uuid++; | ||
this.id = id; | ||
this.deps = !deps.length && callback.length ? defaultDeps : deps; | ||
@@ -114,4 +105,5 @@ this.module = { exports: {} }; | ||
if (loader.wrapModules) { | ||
this.callback = loader.wrapModules(this.name, this.callback); | ||
this.callback = loader.wrapModules(this.id, this.callback); | ||
} | ||
@@ -122,2 +114,3 @@ | ||
var result = this.callback.apply(this, this.reified); | ||
this.reified.length = 0; | ||
this.state = 'finalized'; | ||
@@ -128,3 +121,5 @@ | ||
} | ||
this.makeDefaultExport(); | ||
if (loader.makeDefaultExport) { | ||
this.makeDefaultExport(); | ||
} | ||
return this.module.exports; | ||
@@ -182,3 +177,3 @@ }; | ||
} else { | ||
entry.module = findModule(resolve(dep, this.name), this.name, pending); | ||
entry.module = findModule(resolve(dep, this.id), this.id, pending); | ||
} | ||
@@ -189,9 +184,10 @@ } | ||
Module.prototype.makeRequire = function () { | ||
var name = this.name; | ||
var id = this.id; | ||
var r = function (dep) { | ||
return require(resolve(dep, name)); | ||
return require(resolve(dep, id)); | ||
}; | ||
r['default'] = r; | ||
r.moduleId = id; | ||
r.has = function (dep) { | ||
return has(resolve(dep, name)); | ||
return has(resolve(dep, id)); | ||
}; | ||
@@ -201,6 +197,6 @@ return r; | ||
define = function (name, deps, callback) { | ||
var module = registry[name]; | ||
define = function (id, deps, callback) { | ||
var module = registry[id]; | ||
// If a module for this name has already been defined and is in any state | ||
// If a module for this id has already been defined and is in any state | ||
// other than `new` (meaning it has been or is currently being required), | ||
@@ -216,3 +212,3 @@ // then we return early to avoid redefinition. | ||
if (!_isArray(deps)) { | ||
if (!Array.isArray(deps)) { | ||
callback = deps; | ||
@@ -223,32 +219,55 @@ deps = []; | ||
if (callback instanceof Alias) { | ||
registry[name] = new Module(callback.name, deps, callback, true); | ||
registry[id] = new Module(callback.id, deps, callback, true); | ||
} else { | ||
registry[name] = new Module(name, deps, callback, false); | ||
registry[id] = new Module(id, deps, callback, false); | ||
} | ||
}; | ||
define.exports = function (name, defaultExport) { | ||
var module = registry[name]; | ||
// If a module for this name has already been defined and is in any state | ||
// other than `new` (meaning it has been or is currently being required), | ||
// then we return early to avoid redefinition. | ||
if (module && module.state !== 'new') { | ||
return; | ||
} | ||
module = new Module(name, [], noop, null); | ||
module.module.exports = defaultExport; | ||
module.state = 'finalized'; | ||
registry[name] = module; | ||
return module; | ||
}; | ||
function noop() {} | ||
// we don't support all of AMD | ||
// define.amd = {}; | ||
function Alias(path) { | ||
this.name = path; | ||
function Alias(id) { | ||
this.id = id; | ||
} | ||
define.alias = function (path) { | ||
return new Alias(path); | ||
define.alias = function (id, target) { | ||
if (arguments.length === 2) { | ||
return define(target, new Alias(id)); | ||
} | ||
return new Alias(id); | ||
}; | ||
function missingModule(name, referrer) { | ||
throw new Error('Could not find module `' + name + '` imported from `' + referrer + '`'); | ||
function missingModule(id, referrer) { | ||
throw new Error('Could not find module `' + id + '` imported from `' + referrer + '`'); | ||
} | ||
function findModule(name, referrer, pending) { | ||
var mod = registry[name] || registry[name + '/index']; | ||
function findModule(id, referrer, pending) { | ||
var mod = registry[id] || registry[id + '/index']; | ||
while (mod && mod.isAlias) { | ||
mod = registry[mod.name]; | ||
mod = registry[mod.id] || registry[mod.id + '/index']; | ||
} | ||
if (!mod) { | ||
missingModule(name, referrer); | ||
missingModule(id, referrer); | ||
} | ||
@@ -263,3 +282,3 @@ | ||
function resolve(child, name) { | ||
function resolve(child, id) { | ||
if (child.charAt(0) !== '.') { | ||
@@ -269,4 +288,5 @@ return child; | ||
var parts = child.split('/'); | ||
var nameParts = name.split('/'); | ||
var nameParts = id.split('/'); | ||
var parentBase = nameParts.slice(0, -1); | ||
@@ -292,4 +312,4 @@ | ||
function has(name) { | ||
return !!(registry[name] || registry[name + '/index']); | ||
function has(id) { | ||
return !!(registry[id] || registry[id + '/index']); | ||
} | ||
@@ -299,4 +319,4 @@ | ||
requirejs.has = has; | ||
requirejs.unsee = function (moduleName) { | ||
findModule(moduleName, '(unsee)', false).unsee(); | ||
requirejs.unsee = function (id) { | ||
findModule(id, '(unsee)', false).unsee(); | ||
}; | ||
@@ -320,5 +340,8 @@ | ||
define('foo/quz', define.alias('foo')); | ||
define.alias('foo', 'foo/qux'); | ||
define('foo/bar', ['foo', './quz', './baz', './asdf', './bar', '../foo'], function () {}); | ||
define('foo/main', ['foo/bar'], function () {}); | ||
define.exports('foo/exports', {}); | ||
require('foo/exports'); | ||
require('foo/main'); | ||
@@ -325,0 +348,0 @@ require.unsee('foo/bar'); |
@@ -6,4 +6,2 @@ var loader, define, requireModule, require, requirejs; | ||
var heimdall = global.heimdall; | ||
function dict() { | ||
@@ -25,5 +23,5 @@ var obj = Object.create(null); | ||
requirejs = require = requireModule = function (name) { | ||
requirejs = require = requireModule = function (id) { | ||
var pending = []; | ||
var mod = findModule(name, '(require)', pending); | ||
var mod = findModule(id, '(require)', pending); | ||
@@ -51,14 +49,7 @@ for (var i = pending.length - 1; i >= 0; i--) { | ||
} | ||
} | ||
}, | ||
// Option to enable or disable the generation of default exports | ||
makeDefaultExport: true | ||
}; | ||
var _isArray; | ||
if (!Array.isArray) { | ||
_isArray = function (x) { | ||
return Object.prototype.toString.call(x) === '[object Array]'; | ||
}; | ||
} else { | ||
_isArray = Array.isArray; | ||
} | ||
var registry = dict(); | ||
@@ -70,3 +61,3 @@ var seen = dict(); | ||
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(id, deps, module)` instead got: `' + length + '` arguments to define`'); | ||
} | ||
@@ -76,5 +67,5 @@ | ||
function Module(name, deps, callback, alias) { | ||
this.id = uuid++; | ||
this.name = name; | ||
function Module(id, deps, callback, alias) { | ||
this.uuid = uuid++; | ||
this.id = id; | ||
this.deps = !deps.length && callback.length ? defaultDeps : deps; | ||
@@ -113,4 +104,5 @@ this.module = { exports: {} }; | ||
if (loader.wrapModules) { | ||
this.callback = loader.wrapModules(this.name, this.callback); | ||
this.callback = loader.wrapModules(this.id, this.callback); | ||
} | ||
@@ -121,2 +113,3 @@ | ||
var result = this.callback.apply(this, this.reified); | ||
this.reified.length = 0; | ||
this.state = 'finalized'; | ||
@@ -127,3 +120,5 @@ | ||
} | ||
this.makeDefaultExport(); | ||
if (loader.makeDefaultExport) { | ||
this.makeDefaultExport(); | ||
} | ||
return this.module.exports; | ||
@@ -181,3 +176,3 @@ }; | ||
} else { | ||
entry.module = findModule(resolve(dep, this.name), this.name, pending); | ||
entry.module = findModule(resolve(dep, this.id), this.id, pending); | ||
} | ||
@@ -188,9 +183,10 @@ } | ||
Module.prototype.makeRequire = function () { | ||
var name = this.name; | ||
var id = this.id; | ||
var r = function (dep) { | ||
return require(resolve(dep, name)); | ||
return require(resolve(dep, id)); | ||
}; | ||
r['default'] = r; | ||
r.moduleId = id; | ||
r.has = function (dep) { | ||
return has(resolve(dep, name)); | ||
return has(resolve(dep, id)); | ||
}; | ||
@@ -200,6 +196,6 @@ return r; | ||
define = function (name, deps, callback) { | ||
var module = registry[name]; | ||
define = function (id, deps, callback) { | ||
var module = registry[id]; | ||
// If a module for this name has already been defined and is in any state | ||
// If a module for this id has already been defined and is in any state | ||
// other than `new` (meaning it has been or is currently being required), | ||
@@ -215,3 +211,3 @@ // then we return early to avoid redefinition. | ||
if (!_isArray(deps)) { | ||
if (!Array.isArray(deps)) { | ||
callback = deps; | ||
@@ -222,32 +218,55 @@ deps = []; | ||
if (callback instanceof Alias) { | ||
registry[name] = new Module(callback.name, deps, callback, true); | ||
registry[id] = new Module(callback.id, deps, callback, true); | ||
} else { | ||
registry[name] = new Module(name, deps, callback, false); | ||
registry[id] = new Module(id, deps, callback, false); | ||
} | ||
}; | ||
define.exports = function (name, defaultExport) { | ||
var module = registry[name]; | ||
// If a module for this name has already been defined and is in any state | ||
// other than `new` (meaning it has been or is currently being required), | ||
// then we return early to avoid redefinition. | ||
if (module && module.state !== 'new') { | ||
return; | ||
} | ||
module = new Module(name, [], noop, null); | ||
module.module.exports = defaultExport; | ||
module.state = 'finalized'; | ||
registry[name] = module; | ||
return module; | ||
}; | ||
function noop() {} | ||
// we don't support all of AMD | ||
// define.amd = {}; | ||
function Alias(path) { | ||
this.name = path; | ||
function Alias(id) { | ||
this.id = id; | ||
} | ||
define.alias = function (path) { | ||
return new Alias(path); | ||
define.alias = function (id, target) { | ||
if (arguments.length === 2) { | ||
return define(target, new Alias(id)); | ||
} | ||
return new Alias(id); | ||
}; | ||
function missingModule(name, referrer) { | ||
throw new Error('Could not find module `' + name + '` imported from `' + referrer + '`'); | ||
function missingModule(id, referrer) { | ||
throw new Error('Could not find module `' + id + '` imported from `' + referrer + '`'); | ||
} | ||
function findModule(name, referrer, pending) { | ||
var mod = registry[name] || registry[name + '/index']; | ||
function findModule(id, referrer, pending) { | ||
var mod = registry[id] || registry[id + '/index']; | ||
while (mod && mod.isAlias) { | ||
mod = registry[mod.name]; | ||
mod = registry[mod.id] || registry[mod.id + '/index']; | ||
} | ||
if (!mod) { | ||
missingModule(name, referrer); | ||
missingModule(id, referrer); | ||
} | ||
@@ -262,3 +281,3 @@ | ||
function resolve(child, name) { | ||
function resolve(child, id) { | ||
if (child.charAt(0) !== '.') { | ||
@@ -268,4 +287,5 @@ return child; | ||
var parts = child.split('/'); | ||
var nameParts = name.split('/'); | ||
var nameParts = id.split('/'); | ||
var parentBase = nameParts.slice(0, -1); | ||
@@ -291,4 +311,4 @@ | ||
function has(name) { | ||
return !!(registry[name] || registry[name + '/index']); | ||
function has(id) { | ||
return !!(registry[id] || registry[id + '/index']); | ||
} | ||
@@ -298,4 +318,4 @@ | ||
requirejs.has = has; | ||
requirejs.unsee = function (moduleName) { | ||
findModule(moduleName, '(unsee)', false).unsee(); | ||
requirejs.unsee = function (id) { | ||
findModule(id, '(unsee)', false).unsee(); | ||
}; | ||
@@ -319,5 +339,8 @@ | ||
define('foo/quz', define.alias('foo')); | ||
define.alias('foo', 'foo/qux'); | ||
define('foo/bar', ['foo', './quz', './baz', './asdf', './bar', '../foo'], function () {}); | ||
define('foo/main', ['foo/bar'], function () {}); | ||
define.exports('foo/exports', {}); | ||
require('foo/exports'); | ||
require('foo/main'); | ||
@@ -324,0 +347,0 @@ require.unsee('foo/bar'); |
{ | ||
"name": "mobiledoc-text-renderer", | ||
"version": "0.3.2", | ||
"version": "0.4.0-beta", | ||
"description": "Renders mobiledoc input to text (string) output", | ||
"main": "dist/commonjs/mobiledoc-text-renderer/index.js", | ||
"module": "dist/esm/index.js", | ||
"scripts": { | ||
"test": "testem ci", | ||
"build": "rm -rf dist/ && broccoli build dist" | ||
"build": "rm -rf dist/ && broccoli build dist && npm run transpile", | ||
"transpile": "babel lib --out-dir dist/esm --presets=@babel/preset-env" | ||
}, | ||
@@ -31,2 +33,5 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.2.2", | ||
"@babel/preset-env": "^7.2.3", | ||
"broccoli": "^1.1.1", | ||
@@ -33,0 +38,0 @@ "broccoli-merge-trees": "^2.0.0", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
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
437776
39
8987
8
1