@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,73 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import * as esbuild from "esbuild";
|
|
38
|
-
import { sassPlugin } from "esbuild-sass-plugin";
|
|
39
|
-
import { xMonkeyStripMetadataPlugin } from "./plugins/xmonkey-strip-metadata-plugin.js";
|
|
40
|
-
import { xMonkeyStylesPlugin } from "./plugins/xmonkey-styles-plugin.js";
|
|
41
|
-
export function buildXmonkeyScript(scriptBasePath) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var entryFile;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
entryFile = scriptBasePath;
|
|
48
|
-
console.info("Building file: '".concat(entryFile, "'"));
|
|
49
|
-
return [4, esbuild.build({
|
|
50
|
-
entryPoints: [entryFile],
|
|
51
|
-
outfile: "dist/index.js",
|
|
52
|
-
bundle: true,
|
|
53
|
-
treeShaking: true,
|
|
54
|
-
minify: process.env.DEBUG ? false : true,
|
|
55
|
-
platform: "browser",
|
|
56
|
-
format: "iife",
|
|
57
|
-
sourcemap: false,
|
|
58
|
-
keepNames: true,
|
|
59
|
-
logLevel: "info",
|
|
60
|
-
metafile: true,
|
|
61
|
-
plugins: [
|
|
62
|
-
xMonkeyStripMetadataPlugin(),
|
|
63
|
-
sassPlugin({ style: "compressed" }),
|
|
64
|
-
xMonkeyStylesPlugin(),
|
|
65
|
-
],
|
|
66
|
-
})];
|
|
67
|
-
case 1:
|
|
68
|
-
_a.sent();
|
|
69
|
-
return [2];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { readFile, writeFile } from "fs/promises";
|
|
38
|
-
export function xMonkeyStripMetadataPlugin() {
|
|
39
|
-
return {
|
|
40
|
-
name: "xmonkey-strip-metadata-plugin",
|
|
41
|
-
setup: function (build) {
|
|
42
|
-
var _this = this;
|
|
43
|
-
var foundMetadata = false;
|
|
44
|
-
var metadataContent = "";
|
|
45
|
-
build.onLoad({ filter: /.(ts|tsx)/, namespace: "file" }, function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
46
|
-
var source, scriptMetadataIndex, regex, metadataDecoratorMatcher, startJsonMetadataIndex, endJsonMetadataIndex, metadataJsonString, contents, extension, loader;
|
|
47
|
-
var _a;
|
|
48
|
-
return __generator(this, function (_b) {
|
|
49
|
-
switch (_b.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
if (foundMetadata)
|
|
52
|
-
return [2];
|
|
53
|
-
return [4, readFile(args.path, "utf8")];
|
|
54
|
-
case 1:
|
|
55
|
-
source = _b.sent();
|
|
56
|
-
scriptMetadataIndex = (_a = source.match(/@(ConsoleScript|UiScript)\(/)) === null || _a === void 0 ? void 0 : _a.index;
|
|
57
|
-
if (!scriptMetadataIndex || scriptMetadataIndex < 0)
|
|
58
|
-
return [2];
|
|
59
|
-
foundMetadata = true;
|
|
60
|
-
regex = /\@(ConsoleScript|UiScript)\([^\)]*\)(\.[^\)]*\))?/gi;
|
|
61
|
-
metadataDecoratorMatcher = source.match(regex);
|
|
62
|
-
if (metadataDecoratorMatcher) {
|
|
63
|
-
metadataContent = metadataDecoratorMatcher.at(0);
|
|
64
|
-
startJsonMetadataIndex = metadataContent.indexOf("{");
|
|
65
|
-
endJsonMetadataIndex = metadataContent.lastIndexOf("}");
|
|
66
|
-
metadataJsonString = metadataContent.substring(startJsonMetadataIndex, endJsonMetadataIndex + 1);
|
|
67
|
-
contents = source.replace(metadataJsonString, "");
|
|
68
|
-
extension = args.path.split(".").pop();
|
|
69
|
-
loader = extension === "tsx" ? "tsx" : "ts";
|
|
70
|
-
return [2, { contents: contents, loader: loader }];
|
|
71
|
-
}
|
|
72
|
-
return [2];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}); });
|
|
76
|
-
build.onEnd(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
77
|
-
var fileContents, scriptMetadataString;
|
|
78
|
-
var _a, _b;
|
|
79
|
-
return __generator(this, function (_c) {
|
|
80
|
-
switch (_c.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
if (!((_a = build.initialOptions) === null || _a === void 0 ? void 0 : _a.outfile) || !((_b = build.initialOptions) === null || _b === void 0 ? void 0 : _b.bundle)) {
|
|
83
|
-
console.error("Wrong build configuration. Options 'bundle' must be enabled and 'outfile' must be set.");
|
|
84
|
-
return [2];
|
|
85
|
-
}
|
|
86
|
-
if (!foundMetadata) {
|
|
87
|
-
console.error("ScriptMetadata decorator not found.");
|
|
88
|
-
return [2];
|
|
89
|
-
}
|
|
90
|
-
if (result.errors.length) {
|
|
91
|
-
console.error("Error building. Script Metadata cannot be added to final script.");
|
|
92
|
-
return [2];
|
|
93
|
-
}
|
|
94
|
-
return [4, readFile(build.initialOptions.outfile)];
|
|
95
|
-
case 1:
|
|
96
|
-
fileContents = _c.sent();
|
|
97
|
-
scriptMetadataString = getScriptMetadataString(metadataContent);
|
|
98
|
-
return [4, writeFile(build.initialOptions.outfile, "".concat(scriptMetadataString, "\n\n").concat(fileContents.toString()))];
|
|
99
|
-
case 2:
|
|
100
|
-
_c.sent();
|
|
101
|
-
return [2];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}); });
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function getScriptMetadataString(scriptMetadataFunctionCallString) {
|
|
109
|
-
scriptMetadataFunctionCallString = scriptMetadataFunctionCallString.trim();
|
|
110
|
-
var startJsonMetadataIndex = scriptMetadataFunctionCallString.indexOf("{");
|
|
111
|
-
var endJsonMetadataIndex = scriptMetadataFunctionCallString.lastIndexOf("}");
|
|
112
|
-
if (startJsonMetadataIndex < 0 || endJsonMetadataIndex < 0) {
|
|
113
|
-
return "";
|
|
114
|
-
}
|
|
115
|
-
var metadataObject = JSON.parse(scriptMetadataFunctionCallString
|
|
116
|
-
.substring(startJsonMetadataIndex, endJsonMetadataIndex + 1)
|
|
117
|
-
.replaceAll("\n", "")
|
|
118
|
-
.replaceAll(",}", "}"));
|
|
119
|
-
var tag = "// ==UserScript==";
|
|
120
|
-
var tagEnd = "// ==/UserScript==";
|
|
121
|
-
var headersArr = [];
|
|
122
|
-
var spaces = 13;
|
|
123
|
-
var _loop_1 = function (key) {
|
|
124
|
-
if (Array.isArray(metadataObject[key])) {
|
|
125
|
-
metadataObject[key].forEach(function (item) {
|
|
126
|
-
headersArr.push("".concat(key.padEnd(spaces, " ")).concat(item));
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
headersArr.push("".concat(key.padEnd(spaces, " ")).concat(metadataObject[key]));
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
for (var key in metadataObject) {
|
|
134
|
-
_loop_1(key);
|
|
135
|
-
}
|
|
136
|
-
var headers = headersArr.map(function (h) { return "// ".concat(h); }).join("\n");
|
|
137
|
-
return "".concat(tag, "\n").concat(headers, "\n").concat(tagEnd);
|
|
138
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { appendFile, readFile } from "fs/promises";
|
|
38
|
-
export function xMonkeyStylesPlugin() {
|
|
39
|
-
return {
|
|
40
|
-
name: "xmonkey-styles-plugin",
|
|
41
|
-
setup: function (build) {
|
|
42
|
-
var _this = this;
|
|
43
|
-
build.onEnd(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
44
|
-
var outputs, cssFilePath, file, ext, jsOutFile, cssContents;
|
|
45
|
-
var _a, _b;
|
|
46
|
-
return __generator(this, function (_c) {
|
|
47
|
-
switch (_c.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
if (!((_a = build.initialOptions) === null || _a === void 0 ? void 0 : _a.outfile) || !((_b = build.initialOptions) === null || _b === void 0 ? void 0 : _b.bundle)) {
|
|
50
|
-
console.error("Wrong build configuration. Options 'bundle' must be enabled and 'outfile' must be set.");
|
|
51
|
-
return [2];
|
|
52
|
-
}
|
|
53
|
-
if (!result.metafile) {
|
|
54
|
-
console.warn("ESBuild metafile not enabled. Style bundle skipped.");
|
|
55
|
-
return [2];
|
|
56
|
-
}
|
|
57
|
-
outputs = result.metafile.outputs;
|
|
58
|
-
cssFilePath = "";
|
|
59
|
-
for (file in outputs) {
|
|
60
|
-
ext = file.split(".").pop();
|
|
61
|
-
if (ext === "css") {
|
|
62
|
-
cssFilePath = file;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (!cssFilePath.length) {
|
|
67
|
-
console.warn("CSS output not generated. Style bundle skipped.");
|
|
68
|
-
return [2];
|
|
69
|
-
}
|
|
70
|
-
jsOutFile = build.initialOptions.outfile;
|
|
71
|
-
return [4, readFile(cssFilePath)];
|
|
72
|
-
case 1:
|
|
73
|
-
cssContents = (_c.sent()).toString();
|
|
74
|
-
appendFile(jsOutFile, "\nGM.addStyle(\"\\\n".concat(cssContents.trim(), "\\\n\");"));
|
|
75
|
-
return [2];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}); });
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
17
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
18
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
19
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
20
|
-
function step(op) {
|
|
21
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
22
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
23
|
-
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;
|
|
24
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
25
|
-
switch (op[0]) {
|
|
26
|
-
case 0: case 1: t = op; break;
|
|
27
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
28
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
29
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
30
|
-
default:
|
|
31
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
32
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
33
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
34
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
35
|
-
if (t[2]) _.ops.pop();
|
|
36
|
-
_.trys.pop(); continue;
|
|
37
|
-
}
|
|
38
|
-
op = body.call(thisArg, _);
|
|
39
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
40
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
import { ConsoleScript } from "../decorators/console-script.decorator";
|
|
44
|
-
import { sleep } from "../utils/sleep";
|
|
45
|
-
var ExampleConsoleScript = (function () {
|
|
46
|
-
function ExampleConsoleScript() {
|
|
47
|
-
}
|
|
48
|
-
ExampleConsoleScript.prototype.execute = function () {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var i;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
i = 0;
|
|
55
|
-
_a.label = 1;
|
|
56
|
-
case 1:
|
|
57
|
-
if (!(i < 50)) return [3, 4];
|
|
58
|
-
console.log("Executing script...", i + 1, location.href);
|
|
59
|
-
return [4, sleep(20)];
|
|
60
|
-
case 2:
|
|
61
|
-
_a.sent();
|
|
62
|
-
_a.label = 3;
|
|
63
|
-
case 3:
|
|
64
|
-
i++;
|
|
65
|
-
return [3, 1];
|
|
66
|
-
case 4: return [2];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
ExampleConsoleScript = __decorate([
|
|
72
|
-
ConsoleScript({
|
|
73
|
-
"@name": "Example Console Script",
|
|
74
|
-
"@namespace": "console-scripts",
|
|
75
|
-
"@match": "https://en.wikipedia.org/*",
|
|
76
|
-
"@version": "1.0",
|
|
77
|
-
"@author": "-",
|
|
78
|
-
"@description": "Example Console Script Description",
|
|
79
|
-
"@grant": ["GM.addStyle"],
|
|
80
|
-
})
|
|
81
|
-
], ExampleConsoleScript);
|
|
82
|
-
return ExampleConsoleScript;
|
|
83
|
-
}());
|
|
84
|
-
export { ExampleConsoleScript };
|
package/dist/esm/index.d.ts
DELETED
package/dist/esm/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { buildXmonkeyScript } from "./esbuild/build";
|
|
2
|
-
var entryFile = process.argv[2];
|
|
3
|
-
if (!entryFile) {
|
|
4
|
-
console.error("No entryfile specified. Try adding the script to build in the argument.");
|
|
5
|
-
console.error("Example: npm run build src/example-script.ts");
|
|
6
|
-
process.exit(1);
|
|
7
|
-
}
|
|
8
|
-
buildXmonkeyScript(entryFile);
|
|
9
|
-
export * from "./decorators/console-script.decorator";
|
|
10
|
-
export * from "./decorators/ui-script.decorator";
|
|
11
|
-
export * from "./interfaces";
|
package/dist/esm/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type ScriptInfo = {
|
|
2
|
-
"@name": string;
|
|
3
|
-
"@namespace": string;
|
|
4
|
-
"@match": string;
|
|
5
|
-
"@version": string;
|
|
6
|
-
"@author": string;
|
|
7
|
-
"@description": string;
|
|
8
|
-
"@grant"?: string[];
|
|
9
|
-
[k: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
export type NonFunctionPropertyNames<T> = {
|
|
12
|
-
[K in keyof T]: T[K] extends Function ? never : K;
|
|
13
|
-
}[keyof T];
|
|
14
|
-
export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
|
15
|
-
export type FunctionPropertyNames<T> = {
|
|
16
|
-
[K in keyof T]: T[K] extends Function ? K : never;
|
|
17
|
-
}[keyof T];
|
|
18
|
-
export type ClassConstructor<T> = {
|
|
19
|
-
new (..._: any[]): T;
|
|
20
|
-
};
|
|
21
|
-
export type Self<T> = ClassConstructor<T>;
|
|
22
|
-
export type AnyObject = {
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
};
|
|
25
|
-
export type AnyType = string | number | boolean | AnyObject;
|
|
26
|
-
export type WithRequired<T, K extends keyof T> = T & {
|
|
27
|
-
[P in K]-?: T[P];
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function sleep(ms: number): Promise<void>;
|
package/dist/esm/utils/sleep.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|