@lukaskj/xmonkey 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.js +8 -0
- package/dist/{cjs/decorators → decorators}/console-script.decorator.d.ts +1 -1
- package/dist/{esm/decorators → decorators}/console-script.decorator.js +1 -1
- package/dist/{cjs/decorators → decorators}/ui-script.decorator.d.ts +2 -2
- package/dist/decorators/ui-script.decorator.js +20 -0
- package/dist/esbuild/build.js +26 -0
- package/dist/esbuild/plugins/xmonkey-strip-metadata-plugin.js +77 -0
- package/dist/esbuild/plugins/xmonkey-styles-plugin.js +34 -0
- package/dist/{cjs/example-scripts → example-scripts}/example-console-script.d.ts +1 -1
- package/dist/example-scripts/example-console-script.js +28 -0
- package/dist/{cjs/example-scripts → example-scripts}/example-ui-script.d.ts +1 -1
- package/dist/{esm/example-scripts → example-scripts}/example-ui-script.js +20 -23
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/console-script.interface.js +3 -0
- package/dist/styles/_colors.scss +13 -0
- package/dist/styles/_variables.scss +9 -0
- package/dist/styles/base.scss +4 -0
- package/dist/styles/lit/_base.scss +173 -0
- package/dist/styles/lit/_util.scss +340 -0
- package/dist/styles/lit/index.scss +2 -0
- package/dist/styles/utils.css +70 -0
- package/dist/styles/xmonkey-wrapper.scss +59 -0
- package/dist/types.js +1 -0
- package/dist/{esm/utils → utils}/is-null-or-undefined.js +1 -1
- package/dist/utils/sleep.js +3 -0
- package/dist/{esm/ui/x-monkey-window-component.js → x-monkey-window-component.js} +5 -6
- package/package.json +11 -9
- package/dist/cjs/decorators/console-script.decorator.js +0 -13
- package/dist/cjs/decorators/ui-script.decorator.js +0 -25
- package/dist/cjs/esbuild/build.js +0 -100
- package/dist/cjs/esbuild/plugins/xmonkey-strip-metadata-plugin.js +0 -142
- package/dist/cjs/esbuild/plugins/xmonkey-styles-plugin.js +0 -85
- package/dist/cjs/example-scripts/example-console-script.js +0 -87
- package/dist/cjs/example-scripts/example-ui-script.js +0 -40
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.js +0 -27
- package/dist/cjs/interfaces/console-script.interface.js +0 -7
- package/dist/cjs/interfaces/index.d.ts +0 -2
- package/dist/cjs/interfaces/index.js +0 -18
- package/dist/cjs/interfaces/ui-script.interface.js +0 -2
- package/dist/cjs/types.js +0 -2
- package/dist/cjs/ui/x-monkey-window-component.js +0 -18
- package/dist/cjs/utils/is-null-or-undefined.js +0 -9
- package/dist/cjs/utils/sleep.js +0 -7
- package/dist/esm/decorators/console-script.decorator.d.ts +0 -3
- package/dist/esm/decorators/ui-script.decorator.d.ts +0 -4
- package/dist/esm/decorators/ui-script.decorator.js +0 -21
- package/dist/esm/esbuild/build.d.ts +0 -1
- package/dist/esm/esbuild/build.js +0 -73
- package/dist/esm/esbuild/plugins/xmonkey-strip-metadata-plugin.d.ts +0 -2
- package/dist/esm/esbuild/plugins/xmonkey-strip-metadata-plugin.js +0 -138
- package/dist/esm/esbuild/plugins/xmonkey-styles-plugin.d.ts +0 -2
- package/dist/esm/esbuild/plugins/xmonkey-styles-plugin.js +0 -81
- package/dist/esm/example-scripts/example-console-script.d.ts +0 -4
- package/dist/esm/example-scripts/example-console-script.js +0 -84
- package/dist/esm/example-scripts/example-ui-script.d.ts +0 -6
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/index.js +0 -11
- package/dist/esm/interfaces/console-script.interface.d.ts +0 -6
- package/dist/esm/interfaces/console-script.interface.js +0 -6
- package/dist/esm/interfaces/index.d.ts +0 -2
- package/dist/esm/interfaces/index.js +0 -2
- package/dist/esm/interfaces/ui-script.interface.d.ts +0 -5
- package/dist/esm/types.d.ts +0 -28
- package/dist/esm/ui/x-monkey-window-component.d.ts +0 -7
- package/dist/esm/utils/is-null-or-undefined.d.ts +0 -2
- package/dist/esm/utils/sleep.d.ts +0 -1
- package/dist/esm/utils/sleep.js +0 -3
- /package/dist/{esm/interfaces/ui-script.interface.js → build.d.ts} +0 -0
- /package/dist/{cjs/esbuild → esbuild}/build.d.ts +0 -0
- /package/dist/{cjs/esbuild → esbuild}/plugins/xmonkey-strip-metadata-plugin.d.ts +0 -0
- /package/dist/{cjs/esbuild → esbuild}/plugins/xmonkey-styles-plugin.d.ts +0 -0
- /package/dist/{cjs/interfaces → interfaces}/console-script.interface.d.ts +0 -0
- /package/dist/{cjs/interfaces → interfaces}/ui-script.interface.d.ts +0 -0
- /package/dist/{esm/types.js → interfaces/ui-script.interface.js} +0 -0
- /package/dist/{cjs/types.d.ts → types.d.ts} +0 -0
- /package/dist/{cjs/utils → utils}/is-null-or-undefined.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/sleep.d.ts +0 -0
- /package/dist/{cjs/ui/x-monkey-window-component.d.ts → x-monkey-window-component.d.ts} +0 -0
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.buildXmonkeyScript = void 0;
|
|
63
|
-
var esbuild = __importStar(require("esbuild"));
|
|
64
|
-
var esbuild_sass_plugin_1 = require("esbuild-sass-plugin");
|
|
65
|
-
var xmonkey_strip_metadata_plugin_js_1 = require("./plugins/xmonkey-strip-metadata-plugin.js");
|
|
66
|
-
var xmonkey_styles_plugin_js_1 = require("./plugins/xmonkey-styles-plugin.js");
|
|
67
|
-
function buildXmonkeyScript(scriptBasePath) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
-
var entryFile;
|
|
70
|
-
return __generator(this, function (_a) {
|
|
71
|
-
switch (_a.label) {
|
|
72
|
-
case 0:
|
|
73
|
-
entryFile = scriptBasePath;
|
|
74
|
-
console.info("Building file: '".concat(entryFile, "'"));
|
|
75
|
-
return [4, esbuild.build({
|
|
76
|
-
entryPoints: [entryFile],
|
|
77
|
-
outfile: "dist/index.js",
|
|
78
|
-
bundle: true,
|
|
79
|
-
treeShaking: true,
|
|
80
|
-
minify: process.env.DEBUG ? false : true,
|
|
81
|
-
platform: "browser",
|
|
82
|
-
format: "iife",
|
|
83
|
-
sourcemap: false,
|
|
84
|
-
keepNames: true,
|
|
85
|
-
logLevel: "info",
|
|
86
|
-
metafile: true,
|
|
87
|
-
plugins: [
|
|
88
|
-
(0, xmonkey_strip_metadata_plugin_js_1.xMonkeyStripMetadataPlugin)(),
|
|
89
|
-
(0, esbuild_sass_plugin_1.sassPlugin)({ style: "compressed" }),
|
|
90
|
-
(0, xmonkey_styles_plugin_js_1.xMonkeyStylesPlugin)(),
|
|
91
|
-
],
|
|
92
|
-
})];
|
|
93
|
-
case 1:
|
|
94
|
-
_a.sent();
|
|
95
|
-
return [2];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
exports.buildXmonkeyScript = buildXmonkeyScript;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.xMonkeyStripMetadataPlugin = void 0;
|
|
40
|
-
var promises_1 = require("fs/promises");
|
|
41
|
-
function xMonkeyStripMetadataPlugin() {
|
|
42
|
-
return {
|
|
43
|
-
name: "xmonkey-strip-metadata-plugin",
|
|
44
|
-
setup: function (build) {
|
|
45
|
-
var _this = this;
|
|
46
|
-
var foundMetadata = false;
|
|
47
|
-
var metadataContent = "";
|
|
48
|
-
build.onLoad({ filter: /.(ts|tsx)/, namespace: "file" }, function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
49
|
-
var source, scriptMetadataIndex, regex, metadataDecoratorMatcher, startJsonMetadataIndex, endJsonMetadataIndex, metadataJsonString, contents, extension, loader;
|
|
50
|
-
var _a;
|
|
51
|
-
return __generator(this, function (_b) {
|
|
52
|
-
switch (_b.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
if (foundMetadata)
|
|
55
|
-
return [2];
|
|
56
|
-
return [4, (0, promises_1.readFile)(args.path, "utf8")];
|
|
57
|
-
case 1:
|
|
58
|
-
source = _b.sent();
|
|
59
|
-
scriptMetadataIndex = (_a = source.match(/@(ConsoleScript|UiScript)\(/)) === null || _a === void 0 ? void 0 : _a.index;
|
|
60
|
-
if (!scriptMetadataIndex || scriptMetadataIndex < 0)
|
|
61
|
-
return [2];
|
|
62
|
-
foundMetadata = true;
|
|
63
|
-
regex = /\@(ConsoleScript|UiScript)\([^\)]*\)(\.[^\)]*\))?/gi;
|
|
64
|
-
metadataDecoratorMatcher = source.match(regex);
|
|
65
|
-
if (metadataDecoratorMatcher) {
|
|
66
|
-
metadataContent = metadataDecoratorMatcher.at(0);
|
|
67
|
-
startJsonMetadataIndex = metadataContent.indexOf("{");
|
|
68
|
-
endJsonMetadataIndex = metadataContent.lastIndexOf("}");
|
|
69
|
-
metadataJsonString = metadataContent.substring(startJsonMetadataIndex, endJsonMetadataIndex + 1);
|
|
70
|
-
contents = source.replace(metadataJsonString, "");
|
|
71
|
-
extension = args.path.split(".").pop();
|
|
72
|
-
loader = extension === "tsx" ? "tsx" : "ts";
|
|
73
|
-
return [2, { contents: contents, loader: loader }];
|
|
74
|
-
}
|
|
75
|
-
return [2];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}); });
|
|
79
|
-
build.onEnd(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
80
|
-
var fileContents, scriptMetadataString;
|
|
81
|
-
var _a, _b;
|
|
82
|
-
return __generator(this, function (_c) {
|
|
83
|
-
switch (_c.label) {
|
|
84
|
-
case 0:
|
|
85
|
-
if (!((_a = build.initialOptions) === null || _a === void 0 ? void 0 : _a.outfile) || !((_b = build.initialOptions) === null || _b === void 0 ? void 0 : _b.bundle)) {
|
|
86
|
-
console.error("Wrong build configuration. Options 'bundle' must be enabled and 'outfile' must be set.");
|
|
87
|
-
return [2];
|
|
88
|
-
}
|
|
89
|
-
if (!foundMetadata) {
|
|
90
|
-
console.error("ScriptMetadata decorator not found.");
|
|
91
|
-
return [2];
|
|
92
|
-
}
|
|
93
|
-
if (result.errors.length) {
|
|
94
|
-
console.error("Error building. Script Metadata cannot be added to final script.");
|
|
95
|
-
return [2];
|
|
96
|
-
}
|
|
97
|
-
return [4, (0, promises_1.readFile)(build.initialOptions.outfile)];
|
|
98
|
-
case 1:
|
|
99
|
-
fileContents = _c.sent();
|
|
100
|
-
scriptMetadataString = getScriptMetadataString(metadataContent);
|
|
101
|
-
return [4, (0, promises_1.writeFile)(build.initialOptions.outfile, "".concat(scriptMetadataString, "\n\n").concat(fileContents.toString()))];
|
|
102
|
-
case 2:
|
|
103
|
-
_c.sent();
|
|
104
|
-
return [2];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}); });
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
exports.xMonkeyStripMetadataPlugin = xMonkeyStripMetadataPlugin;
|
|
112
|
-
function getScriptMetadataString(scriptMetadataFunctionCallString) {
|
|
113
|
-
scriptMetadataFunctionCallString = scriptMetadataFunctionCallString.trim();
|
|
114
|
-
var startJsonMetadataIndex = scriptMetadataFunctionCallString.indexOf("{");
|
|
115
|
-
var endJsonMetadataIndex = scriptMetadataFunctionCallString.lastIndexOf("}");
|
|
116
|
-
if (startJsonMetadataIndex < 0 || endJsonMetadataIndex < 0) {
|
|
117
|
-
return "";
|
|
118
|
-
}
|
|
119
|
-
var metadataObject = JSON.parse(scriptMetadataFunctionCallString
|
|
120
|
-
.substring(startJsonMetadataIndex, endJsonMetadataIndex + 1)
|
|
121
|
-
.replaceAll("\n", "")
|
|
122
|
-
.replaceAll(",}", "}"));
|
|
123
|
-
var tag = "// ==UserScript==";
|
|
124
|
-
var tagEnd = "// ==/UserScript==";
|
|
125
|
-
var headersArr = [];
|
|
126
|
-
var spaces = 13;
|
|
127
|
-
var _loop_1 = function (key) {
|
|
128
|
-
if (Array.isArray(metadataObject[key])) {
|
|
129
|
-
metadataObject[key].forEach(function (item) {
|
|
130
|
-
headersArr.push("".concat(key.padEnd(spaces, " ")).concat(item));
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
headersArr.push("".concat(key.padEnd(spaces, " ")).concat(metadataObject[key]));
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
for (var key in metadataObject) {
|
|
138
|
-
_loop_1(key);
|
|
139
|
-
}
|
|
140
|
-
var headers = headersArr.map(function (h) { return "// ".concat(h); }).join("\n");
|
|
141
|
-
return "".concat(tag, "\n").concat(headers, "\n").concat(tagEnd);
|
|
142
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.xMonkeyStylesPlugin = void 0;
|
|
40
|
-
var promises_1 = require("fs/promises");
|
|
41
|
-
function xMonkeyStylesPlugin() {
|
|
42
|
-
return {
|
|
43
|
-
name: "xmonkey-styles-plugin",
|
|
44
|
-
setup: function (build) {
|
|
45
|
-
var _this = this;
|
|
46
|
-
build.onEnd(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
-
var outputs, cssFilePath, file, ext, jsOutFile, cssContents;
|
|
48
|
-
var _a, _b;
|
|
49
|
-
return __generator(this, function (_c) {
|
|
50
|
-
switch (_c.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
if (!((_a = build.initialOptions) === null || _a === void 0 ? void 0 : _a.outfile) || !((_b = build.initialOptions) === null || _b === void 0 ? void 0 : _b.bundle)) {
|
|
53
|
-
console.error("Wrong build configuration. Options 'bundle' must be enabled and 'outfile' must be set.");
|
|
54
|
-
return [2];
|
|
55
|
-
}
|
|
56
|
-
if (!result.metafile) {
|
|
57
|
-
console.warn("ESBuild metafile not enabled. Style bundle skipped.");
|
|
58
|
-
return [2];
|
|
59
|
-
}
|
|
60
|
-
outputs = result.metafile.outputs;
|
|
61
|
-
cssFilePath = "";
|
|
62
|
-
for (file in outputs) {
|
|
63
|
-
ext = file.split(".").pop();
|
|
64
|
-
if (ext === "css") {
|
|
65
|
-
cssFilePath = file;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (!cssFilePath.length) {
|
|
70
|
-
console.warn("CSS output not generated. Style bundle skipped.");
|
|
71
|
-
return [2];
|
|
72
|
-
}
|
|
73
|
-
jsOutFile = build.initialOptions.outfile;
|
|
74
|
-
return [4, (0, promises_1.readFile)(cssFilePath)];
|
|
75
|
-
case 1:
|
|
76
|
-
cssContents = (_c.sent()).toString();
|
|
77
|
-
(0, promises_1.appendFile)(jsOutFile, "\nGM.addStyle(\"\\\n".concat(cssContents.trim(), "\\\n\");"));
|
|
78
|
-
return [2];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}); });
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
exports.xMonkeyStylesPlugin = xMonkeyStylesPlugin;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
-
function step(op) {
|
|
22
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
24
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
-
switch (op[0]) {
|
|
27
|
-
case 0: case 1: t = op; break;
|
|
28
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
-
default:
|
|
32
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
-
if (t[2]) _.ops.pop();
|
|
37
|
-
_.trys.pop(); continue;
|
|
38
|
-
}
|
|
39
|
-
op = body.call(thisArg, _);
|
|
40
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.ExampleConsoleScript = void 0;
|
|
46
|
-
var console_script_decorator_1 = require("../decorators/console-script.decorator");
|
|
47
|
-
var sleep_1 = require("../utils/sleep");
|
|
48
|
-
var ExampleConsoleScript = (function () {
|
|
49
|
-
function ExampleConsoleScript() {
|
|
50
|
-
}
|
|
51
|
-
ExampleConsoleScript.prototype.execute = function () {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
var i;
|
|
54
|
-
return __generator(this, function (_a) {
|
|
55
|
-
switch (_a.label) {
|
|
56
|
-
case 0:
|
|
57
|
-
i = 0;
|
|
58
|
-
_a.label = 1;
|
|
59
|
-
case 1:
|
|
60
|
-
if (!(i < 50)) return [3, 4];
|
|
61
|
-
console.log("Executing script...", i + 1, location.href);
|
|
62
|
-
return [4, (0, sleep_1.sleep)(20)];
|
|
63
|
-
case 2:
|
|
64
|
-
_a.sent();
|
|
65
|
-
_a.label = 3;
|
|
66
|
-
case 3:
|
|
67
|
-
i++;
|
|
68
|
-
return [3, 1];
|
|
69
|
-
case 4: return [2];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
ExampleConsoleScript = __decorate([
|
|
75
|
-
(0, console_script_decorator_1.ConsoleScript)({
|
|
76
|
-
"@name": "Example Console Script",
|
|
77
|
-
"@namespace": "console-scripts",
|
|
78
|
-
"@match": "https://en.wikipedia.org/*",
|
|
79
|
-
"@version": "1.0",
|
|
80
|
-
"@author": "-",
|
|
81
|
-
"@description": "Example Console Script Description",
|
|
82
|
-
"@grant": ["GM.addStyle"],
|
|
83
|
-
})
|
|
84
|
-
], ExampleConsoleScript);
|
|
85
|
-
return ExampleConsoleScript;
|
|
86
|
-
}());
|
|
87
|
-
exports.ExampleConsoleScript = ExampleConsoleScript;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ExampleUiScript = void 0;
|
|
10
|
-
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
11
|
-
var ui_script_decorator_1 = require("../decorators/ui-script.decorator");
|
|
12
|
-
var hooks_1 = require("preact/hooks");
|
|
13
|
-
require("./example-scss.scss");
|
|
14
|
-
var ExampleUiScript = (function () {
|
|
15
|
-
function ExampleUiScript() {
|
|
16
|
-
this.title = "Example UI Script";
|
|
17
|
-
}
|
|
18
|
-
ExampleUiScript.prototype.render = function () {
|
|
19
|
-
return (0, jsx_runtime_1.jsx)(JsxUiExample, {});
|
|
20
|
-
};
|
|
21
|
-
ExampleUiScript = __decorate([
|
|
22
|
-
(0, ui_script_decorator_1.UiScript)({
|
|
23
|
-
"@name": "Example Console Script",
|
|
24
|
-
"@namespace": "console-scripts",
|
|
25
|
-
"@match": "https://en.wikipedia.org/*",
|
|
26
|
-
"@version": "1.0",
|
|
27
|
-
"@author": "-",
|
|
28
|
-
"@description": "Example Console Script Description",
|
|
29
|
-
"@grant": ["GM.addStyle"],
|
|
30
|
-
})
|
|
31
|
-
], ExampleUiScript);
|
|
32
|
-
return ExampleUiScript;
|
|
33
|
-
}());
|
|
34
|
-
exports.ExampleUiScript = ExampleUiScript;
|
|
35
|
-
function JsxUiExample() {
|
|
36
|
-
var _a = (0, hooks_1.useState)(0), count = _a[0], setCount = _a[1];
|
|
37
|
-
var increment = function () { return setCount(count + 1); };
|
|
38
|
-
var decrement = function () { return setCount(function (currentCount) { return currentCount - 1; }); };
|
|
39
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("p", { children: ["Count: ", count] }), (0, jsx_runtime_1.jsxs)("div", { class: "w-100 d--f jc--c", children: [(0, jsx_runtime_1.jsx)("button", { class: "btn small primary", onClick: increment, children: "Increment" }), (0, jsx_runtime_1.jsx)("button", { class: "btn small primary", onClick: decrement, children: "Decrement" })] })] }));
|
|
40
|
-
}
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var build_1 = require("./esbuild/build");
|
|
18
|
-
var entryFile = process.argv[2];
|
|
19
|
-
if (!entryFile) {
|
|
20
|
-
console.error("No entryfile specified. Try adding the script to build in the argument.");
|
|
21
|
-
console.error("Example: npm run build src/example-script.ts");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
(0, build_1.buildXmonkeyScript)(entryFile);
|
|
25
|
-
__exportStar(require("./decorators/console-script.decorator"), exports);
|
|
26
|
-
__exportStar(require("./decorators/ui-script.decorator"), exports);
|
|
27
|
-
__exportStar(require("./interfaces"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./console-script.interface"), exports);
|
|
18
|
-
__exportStar(require("./ui-script.interface"), exports);
|
package/dist/cjs/types.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XMonkeyWindowComponent = void 0;
|
|
4
|
-
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
5
|
-
var hooks_1 = require("preact/hooks");
|
|
6
|
-
function XMonkeyWindowComponent(props) {
|
|
7
|
-
var _a = (0, hooks_1.useState)(false), minimized = _a[0], setMinimized = _a[1];
|
|
8
|
-
function toggleMinimize() {
|
|
9
|
-
setMinimized(!minimized);
|
|
10
|
-
}
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "xmwr_c d--f fd--c ai--c jc--sb", children: [(0, jsx_runtime_1.jsxs)("div", { className: "xmwr-h w-100 m0 d--f fd--r jc--c bg-primary noselect", children: [(0, jsx_runtime_1.jsx)("div", { className: "xmwr-title m0", children: props.title }), (0, jsx_runtime_1.jsx)(MinimizeButton, { toggleMinimize: toggleMinimize, minimized: minimized })] }), (0, jsx_runtime_1.jsx)("div", { className: "xmwr-b w-100 d--f jc--c " + (minimized ? "b-collapsed" : ""), children: props.children })] }));
|
|
12
|
-
}
|
|
13
|
-
exports.XMonkeyWindowComponent = XMonkeyWindowComponent;
|
|
14
|
-
function MinimizeButton(_a) {
|
|
15
|
-
var minimized = _a.minimized, toggleMinimize = _a.toggleMinimize;
|
|
16
|
-
var minimizeChar = minimized ? "+" : "-";
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "xmwr-x m0", onClick: function () { return toggleMinimize(); }, children: minimizeChar }));
|
|
18
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNullOrEmptyOrUndefined = exports.isNullOrUndefined = void 0;
|
|
4
|
-
var isNullOrUndefined = function (value) { return value === null || value === undefined; };
|
|
5
|
-
exports.isNullOrUndefined = isNullOrUndefined;
|
|
6
|
-
function isNullOrEmptyOrUndefined(value) {
|
|
7
|
-
return (0, exports.isNullOrUndefined)(value) || value === "" || value.toString().trim() === "";
|
|
8
|
-
}
|
|
9
|
-
exports.isNullOrEmptyOrUndefined = isNullOrEmptyOrUndefined;
|
package/dist/cjs/utils/sleep.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { h, render } from "preact";
|
|
2
|
-
import { XMonkeyWindowComponent } from "../ui/x-monkey-window-component";
|
|
3
|
-
import "../ui/styles/base.scss";
|
|
4
|
-
export function UiScript(_metadata) {
|
|
5
|
-
return function (_target) {
|
|
6
|
-
var _a;
|
|
7
|
-
var scriptObject = new _target();
|
|
8
|
-
var rootComponent = xMonkeyWrapperElement();
|
|
9
|
-
render(h(XMonkeyWindowComponent, { title: (_a = scriptObject.title) !== null && _a !== void 0 ? _a : "" }, scriptObject.render()), rootComponent);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function xMonkeyWrapperElement() {
|
|
13
|
-
var ID = "__xmwr";
|
|
14
|
-
var div = document.getElementById(ID);
|
|
15
|
-
if (div)
|
|
16
|
-
return div;
|
|
17
|
-
div = document.createElement("div");
|
|
18
|
-
div.id = ID;
|
|
19
|
-
document.body.appendChild(div);
|
|
20
|
-
return div;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function buildXmonkeyScript(scriptBasePath: string): Promise<void>;
|