Add bundler

This commit is contained in:
Sol Fisher Romanoff 2022-07-08 21:25:04 +03:00
parent 0f60653105
commit 1dde5177ea
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62
7 changed files with 786 additions and 4 deletions

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
lib

View file

@ -16,5 +16,13 @@ pipeline:
- pull_request - pull_request
image: node:16 image: node:16
commands: commands:
- npm install
- npm run test - npm run test
build:
when:
event:
- push
- pull_request
image: node:16
commands:
- npm run build

274
lib/index.cjs Normal file
View file

@ -0,0 +1,274 @@
'use strict';
function _wrapRegExp() {
_wrapRegExp = function (re, groups) {
return new BabelRegExp(re, void 0, groups);
};
var _super = RegExp.prototype,
_groups = new WeakMap();
function BabelRegExp(re, flags, groups) {
var _this = new RegExp(re, flags);
return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype);
}
function buildGroups(result, re) {
var g = _groups.get(re);
return Object.keys(g).reduce(function (groups, name) {
return groups[name] = result[g[name]], groups;
}, Object.create(null));
}
return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
var result = _super.exec.call(this, str);
return result && (result.groups = buildGroups(result, this)), result;
}, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
if ("string" == typeof substitution) {
var groups = _groups.get(this);
return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
return "$" + groups[name];
}));
}
if ("function" == typeof substitution) {
var _this = this;
return _super[Symbol.replace].call(this, str, function () {
var args = arguments;
return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
});
}
return _super[Symbol.replace].call(this, str, substitution);
}, _wrapRegExp.apply(this, arguments);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
var index = {
extensions: [{
name: 'mfm',
level: 'inline',
start: function start(src) {
var _src$match;
return (_src$match = src.match(/\$\[/)) == null ? void 0 : _src$match.index;
},
tokenizer: function tokenizer(src, tokens) {
// regex doesn't do well finding MFM tags: it's always either too lazy
// or too greedy.
var level = 0;
var walk = 0;
while (level > 0 || walk === 0) {
if (src[walk] + src[walk + 1] === '$[') {
level++;
walk++;
} else if (src[walk] === ']') {
level--;
}
walk++;
} // original regex, now definitely on the correct tag
var rule = /*#__PURE__*/_wrapRegExp(/^\$\[([\w\d]+)(?:\.(\S+))? ([\S\s]+)\]/, {
markup: 1,
options: 2,
text: 3
});
var match = rule.exec(src.slice(0, walk));
if (match) {
var token = {
type: 'mfm',
raw: match[0],
markup: match.groups.markup,
options: match.groups.options,
text: match.groups.text,
tokens: []
};
this.lexer.inline(token.text, token.tokens);
return token;
}
},
renderer: function renderer(token) {
var _this = this;
var options = {};
if (token.options) {
options = token.options.split(',').reduce(function (i, opt) {
i[opt.split('=')[0]] = opt.split('=')[1] || true;
return i;
}, {});
}
var el = function el(mfmClass, mfmStyle) {
if (mfmStyle === void 0) {
mfmStyle = '';
}
return "<span style=\"display: inline-block;" + mfmStyle + "\" class=\"" + mfmClass + "\">" + _this.parser.parseInline(token.tokens) + "</span>";
};
switch (token.markup) {
case 'blur':
{
return el('_mfm_blur_');
}
case 'bounce':
{
return el('_mfm_bounce_');
}
case 'flip':
{
var transform = options.x && options.v ? 'scale(-1, -1)' : options.v ? 'scaleY(-1)' : 'scaleX(-1)';
return el('_mfm_flip_', " transform: " + transform + ";");
}
case 'font':
{
var family = options.serif ? 'serif' : options.monospace ? 'monospace' : options.cursive ? 'cursive' : options.fantasy ? 'fantasy' : options.emoji ? 'emoji' : options.math ? 'math' : 'inherit';
return el('_mfm_font_', " font-family: " + family + ";");
}
case 'jelly':
{
var speed = options.speed || '1s';
return el('_mfm_jelly_', " animation: mfm-rubberBand " + speed + " linear infinite both;");
}
case 'jump':
{
return el('_mfm_jump_');
}
case 'rainbow':
{
return el('_mfm_rainbow_');
}
case 'rotate':
{
var degrees = options.deg || '90';
return el('_mfm_rotate_', " transform: rotate(" + degrees + "deg); transform-origin: center center;");
}
case 'shake':
{
var _speed = options.speed || '0.5s';
return el('_mfm_shake_', " animation: mfm-shake " + _speed + " ease infinite;");
}
case 'spin':
{
var direction = options.left ? 'reverse' : options.alternate ? 'alternate' : 'normal';
var anime = options.x ? 'mfm-spinX' : options.y ? 'mfm-spinY' : 'mfm-spin';
var _speed2 = options.speed || '1.5s';
return el('_mfm_spin_', " animation: " + anime + " " + _speed2 + " linear infinite; animation-direction: " + direction + ";");
}
case 'tada':
{
return el('_mfm_tada_');
}
case 'twitch':
{
var _speed3 = options.speed || '0.5s';
return el('_mfm_twitch_', " animation: mfm-twitch " + _speed3 + " ease infinite;");
}
case 'sparkle':
{
return el('_mfm_sparkle_');
}
case 'x2':
{
return el('_mfm_x2_');
}
case 'x3':
{
return el('_mfm_x3_');
}
case 'x4':
{
return el('_mfm_x4_');
}
default:
{
return "$[" + token.markup + " " + this.parser.parseInline(token.tokens) + "]";
}
}
}
}, {
name: 'mfmSearch',
level: 'block',
start: function start(src) {
var _src$match2;
return (_src$match2 = src.match(/[^\n]+ search/)) == null ? void 0 : _src$match2.index;
},
tokenizer: function tokenizer(src, tokens) {
var rule = /^([^\n]+) search$/;
var match = rule.exec(src);
if (match) {
var token = {
type: 'mfmSearch',
raw: match[0],
query: match[1].trim(),
tokens: []
};
this.lexer.inline(token.text, token.tokens);
return token;
}
},
renderer: function renderer(token) {
return "<a href=\"https://google.com/search?q=" + token.query + "\" class=\"_mfm_search_\">" + token.raw + "</a>";
}
}]
};
module.exports = index;

280
lib/index.umd.js Normal file
View file

@ -0,0 +1,280 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.markedMfm = factory());
})(this, (function () { 'use strict';
function _wrapRegExp() {
_wrapRegExp = function (re, groups) {
return new BabelRegExp(re, void 0, groups);
};
var _super = RegExp.prototype,
_groups = new WeakMap();
function BabelRegExp(re, flags, groups) {
var _this = new RegExp(re, flags);
return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype);
}
function buildGroups(result, re) {
var g = _groups.get(re);
return Object.keys(g).reduce(function (groups, name) {
return groups[name] = result[g[name]], groups;
}, Object.create(null));
}
return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
var result = _super.exec.call(this, str);
return result && (result.groups = buildGroups(result, this)), result;
}, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
if ("string" == typeof substitution) {
var groups = _groups.get(this);
return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
return "$" + groups[name];
}));
}
if ("function" == typeof substitution) {
var _this = this;
return _super[Symbol.replace].call(this, str, function () {
var args = arguments;
return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
});
}
return _super[Symbol.replace].call(this, str, substitution);
}, _wrapRegExp.apply(this, arguments);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
var index = {
extensions: [{
name: 'mfm',
level: 'inline',
start: function start(src) {
var _src$match;
return (_src$match = src.match(/\$\[/)) == null ? void 0 : _src$match.index;
},
tokenizer: function tokenizer(src, tokens) {
// regex doesn't do well finding MFM tags: it's always either too lazy
// or too greedy.
var level = 0;
var walk = 0;
while (level > 0 || walk === 0) {
if (src[walk] + src[walk + 1] === '$[') {
level++;
walk++;
} else if (src[walk] === ']') {
level--;
}
walk++;
} // original regex, now definitely on the correct tag
var rule = /*#__PURE__*/_wrapRegExp(/^\$\[([\w\d]+)(?:\.(\S+))? ([\S\s]+)\]/, {
markup: 1,
options: 2,
text: 3
});
var match = rule.exec(src.slice(0, walk));
if (match) {
var token = {
type: 'mfm',
raw: match[0],
markup: match.groups.markup,
options: match.groups.options,
text: match.groups.text,
tokens: []
};
this.lexer.inline(token.text, token.tokens);
return token;
}
},
renderer: function renderer(token) {
var _this = this;
var options = {};
if (token.options) {
options = token.options.split(',').reduce(function (i, opt) {
i[opt.split('=')[0]] = opt.split('=')[1] || true;
return i;
}, {});
}
var el = function el(mfmClass, mfmStyle) {
if (mfmStyle === void 0) {
mfmStyle = '';
}
return "<span style=\"display: inline-block;" + mfmStyle + "\" class=\"" + mfmClass + "\">" + _this.parser.parseInline(token.tokens) + "</span>";
};
switch (token.markup) {
case 'blur':
{
return el('_mfm_blur_');
}
case 'bounce':
{
return el('_mfm_bounce_');
}
case 'flip':
{
var transform = options.x && options.v ? 'scale(-1, -1)' : options.v ? 'scaleY(-1)' : 'scaleX(-1)';
return el('_mfm_flip_', " transform: " + transform + ";");
}
case 'font':
{
var family = options.serif ? 'serif' : options.monospace ? 'monospace' : options.cursive ? 'cursive' : options.fantasy ? 'fantasy' : options.emoji ? 'emoji' : options.math ? 'math' : 'inherit';
return el('_mfm_font_', " font-family: " + family + ";");
}
case 'jelly':
{
var speed = options.speed || '1s';
return el('_mfm_jelly_', " animation: mfm-rubberBand " + speed + " linear infinite both;");
}
case 'jump':
{
return el('_mfm_jump_');
}
case 'rainbow':
{
return el('_mfm_rainbow_');
}
case 'rotate':
{
var degrees = options.deg || '90';
return el('_mfm_rotate_', " transform: rotate(" + degrees + "deg); transform-origin: center center;");
}
case 'shake':
{
var _speed = options.speed || '0.5s';
return el('_mfm_shake_', " animation: mfm-shake " + _speed + " ease infinite;");
}
case 'spin':
{
var direction = options.left ? 'reverse' : options.alternate ? 'alternate' : 'normal';
var anime = options.x ? 'mfm-spinX' : options.y ? 'mfm-spinY' : 'mfm-spin';
var _speed2 = options.speed || '1.5s';
return el('_mfm_spin_', " animation: " + anime + " " + _speed2 + " linear infinite; animation-direction: " + direction + ";");
}
case 'tada':
{
return el('_mfm_tada_');
}
case 'twitch':
{
var _speed3 = options.speed || '0.5s';
return el('_mfm_twitch_', " animation: mfm-twitch " + _speed3 + " ease infinite;");
}
case 'sparkle':
{
return el('_mfm_sparkle_');
}
case 'x2':
{
return el('_mfm_x2_');
}
case 'x3':
{
return el('_mfm_x3_');
}
case 'x4':
{
return el('_mfm_x4_');
}
default:
{
return "$[" + token.markup + " " + this.parser.parseInline(token.tokens) + "]";
}
}
}
}, {
name: 'mfmSearch',
level: 'block',
start: function start(src) {
var _src$match2;
return (_src$match2 = src.match(/[^\n]+ search/)) == null ? void 0 : _src$match2.index;
},
tokenizer: function tokenizer(src, tokens) {
var rule = /^([^\n]+) search$/;
var match = rule.exec(src);
if (match) {
var token = {
type: 'mfmSearch',
raw: match[0],
query: match[1].trim(),
tokens: []
};
this.lexer.inline(token.text, token.tokens);
return token;
}
},
renderer: function renderer(token) {
return "<a href=\"https://google.com/search?q=" + token.query + "\" class=\"_mfm_search_\">" + token.raw + "</a>";
}
}]
};
return index;
}));

202
package-lock.json generated
View file

@ -11,11 +11,14 @@
"dependencies": { "dependencies": {
"@babel/core": "^7.18.6", "@babel/core": "^7.18.6",
"@babel/preset-env": "^7.18.6", "@babel/preset-env": "^7.18.6",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.1",
"babel-jest": "^28.1.2", "babel-jest": "^28.1.2",
"eslint": "^8.19.0", "eslint": "^8.19.0",
"eslint-config-standard": "^17.0.0", "eslint-config-standard": "^17.0.0",
"eslint-plugin-jest": "^26.5.3", "eslint-plugin-jest": "^26.5.3",
"jest-cli": "^28.1.2" "jest-cli": "^28.1.2",
"rollup": "^2.76.0"
}, },
"peerDependencies": { "peerDependencies": {
"marked": "^4.0.17" "marked": "^4.0.17"
@ -2164,6 +2167,69 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/@rollup/plugin-babel": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
"integrity": "sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==",
"dependencies": {
"@babel/helper-module-imports": "^7.10.4",
"@rollup/pluginutils": "^3.1.0"
},
"engines": {
"node": ">= 10.0.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0",
"@types/babel__core": "^7.1.9",
"rollup": "^1.20.0||^2.0.0"
},
"peerDependenciesMeta": {
"@types/babel__core": {
"optional": true
}
}
},
"node_modules/@rollup/plugin-commonjs": {
"version": "22.0.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-22.0.1.tgz",
"integrity": "sha512-dGfEZvdjDHObBiP5IvwTKMVeq/tBZGMBHZFMdIV1ClMM/YoWS34xrHFGfag9SN2ZtMgNZRFruqvxZQEa70O6nQ==",
"dependencies": {
"@rollup/pluginutils": "^3.1.0",
"commondir": "^1.0.1",
"estree-walker": "^2.0.1",
"glob": "^7.1.6",
"is-reference": "^1.2.1",
"magic-string": "^0.25.7",
"resolve": "^1.17.0"
},
"engines": {
"node": ">= 12.0.0"
},
"peerDependencies": {
"rollup": "^2.68.0"
}
},
"node_modules/@rollup/pluginutils": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz",
"integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==",
"dependencies": {
"@types/estree": "0.0.39",
"estree-walker": "^1.0.1",
"picomatch": "^2.2.2"
},
"engines": {
"node": ">= 8.0.0"
},
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0"
}
},
"node_modules/@rollup/pluginutils/node_modules/estree-walker": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
"integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg=="
},
"node_modules/@sinclair/typebox": { "node_modules/@sinclair/typebox": {
"version": "0.23.5", "version": "0.23.5",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.23.5.tgz", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.23.5.tgz",
@ -2222,6 +2288,11 @@
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
} }
}, },
"node_modules/@types/estree": {
"version": "0.0.39",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw=="
},
"node_modules/@types/graceful-fs": { "node_modules/@types/graceful-fs": {
"version": "4.1.5", "version": "4.1.5",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz",
@ -2874,6 +2945,11 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
}, },
"node_modules/commondir": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
"integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg=="
},
"node_modules/concat-map": { "node_modules/concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -3493,6 +3569,11 @@
"node": ">=4.0" "node": ">=4.0"
} }
}, },
"node_modules/estree-walker": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
},
"node_modules/esutils": { "node_modules/esutils": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
@ -4137,6 +4218,14 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/is-reference": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
"dependencies": {
"@types/estree": "*"
}
},
"node_modules/is-regex": { "node_modules/is-regex": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz",
@ -4923,6 +5012,14 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"dependencies": {
"sourcemap-codec": "^1.4.8"
}
},
"node_modules/make-dir": { "node_modules/make-dir": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@ -5597,6 +5694,20 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/rollup": {
"version": "2.76.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.76.0.tgz",
"integrity": "sha512-9jwRIEY1jOzKLj3nsY/yot41r19ITdQrhs+q3ggNWhr9TQgduHqANvPpS32RNpzGklJu3G1AJfvlZLi/6wFgWA==",
"bin": {
"rollup": "dist/bin/rollup"
},
"engines": {
"node": ">=10.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/run-parallel": { "node_modules/run-parallel": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
@ -5706,6 +5817,11 @@
"source-map": "^0.6.0" "source-map": "^0.6.0"
} }
}, },
"node_modules/sourcemap-codec": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA=="
},
"node_modules/sprintf-js": { "node_modules/sprintf-js": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
@ -7721,6 +7837,46 @@
"fastq": "^1.6.0" "fastq": "^1.6.0"
} }
}, },
"@rollup/plugin-babel": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
"integrity": "sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==",
"requires": {
"@babel/helper-module-imports": "^7.10.4",
"@rollup/pluginutils": "^3.1.0"
}
},
"@rollup/plugin-commonjs": {
"version": "22.0.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-22.0.1.tgz",
"integrity": "sha512-dGfEZvdjDHObBiP5IvwTKMVeq/tBZGMBHZFMdIV1ClMM/YoWS34xrHFGfag9SN2ZtMgNZRFruqvxZQEa70O6nQ==",
"requires": {
"@rollup/pluginutils": "^3.1.0",
"commondir": "^1.0.1",
"estree-walker": "^2.0.1",
"glob": "^7.1.6",
"is-reference": "^1.2.1",
"magic-string": "^0.25.7",
"resolve": "^1.17.0"
}
},
"@rollup/pluginutils": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz",
"integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==",
"requires": {
"@types/estree": "0.0.39",
"estree-walker": "^1.0.1",
"picomatch": "^2.2.2"
},
"dependencies": {
"estree-walker": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
"integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg=="
}
}
},
"@sinclair/typebox": { "@sinclair/typebox": {
"version": "0.23.5", "version": "0.23.5",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.23.5.tgz", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.23.5.tgz",
@ -7779,6 +7935,11 @@
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
} }
}, },
"@types/estree": {
"version": "0.0.39",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw=="
},
"@types/graceful-fs": { "@types/graceful-fs": {
"version": "4.1.5", "version": "4.1.5",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz",
@ -8250,6 +8411,11 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
}, },
"commondir": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
"integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg=="
},
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -8691,6 +8857,11 @@
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==" "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA=="
}, },
"estree-walker": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
},
"esutils": { "esutils": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
@ -9141,6 +9312,14 @@
"has-tostringtag": "^1.0.0" "has-tostringtag": "^1.0.0"
} }
}, },
"is-reference": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
"requires": {
"@types/estree": "*"
}
},
"is-regex": { "is-regex": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz",
@ -9738,6 +9917,14 @@
"yallist": "^4.0.0" "yallist": "^4.0.0"
} }
}, },
"magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"requires": {
"sourcemap-codec": "^1.4.8"
}
},
"make-dir": { "make-dir": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@ -10212,6 +10399,14 @@
"glob": "^7.1.3" "glob": "^7.1.3"
} }
}, },
"rollup": {
"version": "2.76.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.76.0.tgz",
"integrity": "sha512-9jwRIEY1jOzKLj3nsY/yot41r19ITdQrhs+q3ggNWhr9TQgduHqANvPpS32RNpzGklJu3G1AJfvlZLi/6wFgWA==",
"requires": {
"fsevents": "~2.3.2"
}
},
"run-parallel": { "run-parallel": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
@ -10286,6 +10481,11 @@
"source-map": "^0.6.0" "source-map": "^0.6.0"
} }
}, },
"sourcemap-codec": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA=="
},
"sprintf-js": { "sprintf-js": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",

View file

@ -3,11 +3,13 @@
"version": "0.1.1", "version": "0.1.1",
"description": "Marked.js extension for Misskey-flavored Markdown", "description": "Marked.js extension for Misskey-flavored Markdown",
"main": "./src/index.js", "main": "./src/index.js",
"browser": "./lib/index.umd.js",
"type": "module", "type": "module",
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
"lint-fix": "eslint --fix .", "lint-fix": "eslint --fix .",
"test": "jest --verbose" "test": "jest --verbose",
"build": "rollup -c rollup.config.umd.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -24,10 +26,13 @@
"dependencies": { "dependencies": {
"@babel/core": "^7.18.6", "@babel/core": "^7.18.6",
"@babel/preset-env": "^7.18.6", "@babel/preset-env": "^7.18.6",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.1",
"babel-jest": "^28.1.2", "babel-jest": "^28.1.2",
"eslint": "^8.19.0", "eslint": "^8.19.0",
"eslint-config-standard": "^17.0.0", "eslint-config-standard": "^17.0.0",
"eslint-plugin-jest": "^26.5.3", "eslint-plugin-jest": "^26.5.3",
"jest-cli": "^28.1.2" "jest-cli": "^28.1.2",
"rollup": "^2.76.0"
} }
} }

14
rollup.config.umd.js Normal file
View file

@ -0,0 +1,14 @@
const babel = require('@rollup/plugin-babel').default
export default {
input: 'src/index.js',
output: {
name: 'markedMfm',
file: 'lib/index.umd.js',
exports: 'default',
format: 'umd',
},
plugins: [
babel({ presets: [['@babel/preset-env', { loose: true }]] }),
],
}