@dodona/papyros 4.0.0-beta.4 → 4.0.0-beta.5
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/Papyros.js.map +1 -1
- package/dist/backend/workers/python/python_package.tar.gz.load_by_url +0 -0
- package/dist/frontend/components/Input.d.ts +2 -6
- package/dist/frontend/components/Input.js +7 -15
- package/dist/frontend/components/Input.js.map +1 -1
- package/dist/frontend/components/input/BatchInput.d.ts +0 -10
- package/dist/frontend/components/input/BatchInput.js +3 -42
- package/dist/frontend/components/input/BatchInput.js.map +1 -1
- package/dist/frontend/state/Debugger.js +3 -0
- package/dist/frontend/state/Debugger.js.map +1 -1
- package/dist/frontend/state/InputOutput.d.ts +9 -0
- package/dist/frontend/state/InputOutput.js +40 -0
- package/dist/frontend/state/InputOutput.js.map +1 -1
- package/dist/util/Util.d.ts +0 -40
- package/dist/util/Util.js +0 -90
- package/dist/util/Util.js.map +1 -1
- package/package.json +1 -1
package/dist/Papyros.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Papyros.js","sourceRoot":"","sources":["../src/Papyros.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Papyros.js","sourceRoot":"","sources":["../src/Papyros.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
|
3
3
|
import "./input/InteractiveInput";
|
|
4
4
|
import { PapyrosElement } from "./PapyrosElement";
|
|
5
5
|
import "@material/web/switch/switch";
|
|
6
|
-
|
|
7
|
-
batch = "batch",
|
|
8
|
-
interactive = "interactive"
|
|
9
|
-
}
|
|
6
|
+
import { InputMode } from "../state/InputOutput";
|
|
10
7
|
export declare class Input extends PapyrosElement {
|
|
11
|
-
mode: InputMode;
|
|
12
8
|
static get styles(): CSSResult;
|
|
9
|
+
get mode(): InputMode;
|
|
13
10
|
get otherMode(): InputMode;
|
|
14
11
|
toggleMode(): void;
|
|
15
12
|
protected render(): TemplateResult;
|
|
16
13
|
}
|
|
17
|
-
export {};
|
|
@@ -4,22 +4,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { customElement
|
|
7
|
+
import { customElement } from "lit/decorators.js";
|
|
8
8
|
import { css, html } from "lit";
|
|
9
9
|
import "./input/BatchInput";
|
|
10
10
|
import "./input/InteractiveInput";
|
|
11
11
|
import { PapyrosElement } from "./PapyrosElement";
|
|
12
12
|
import "@material/web/switch/switch";
|
|
13
|
-
|
|
14
|
-
(function (InputMode) {
|
|
15
|
-
InputMode["batch"] = "batch";
|
|
16
|
-
InputMode["interactive"] = "interactive";
|
|
17
|
-
})(InputMode || (InputMode = {}));
|
|
13
|
+
import { InputMode } from "../state/InputOutput";
|
|
18
14
|
let Input = class Input extends PapyrosElement {
|
|
19
|
-
constructor() {
|
|
20
|
-
super(...arguments);
|
|
21
|
-
this.mode = InputMode.interactive;
|
|
22
|
-
}
|
|
23
15
|
static get styles() {
|
|
24
16
|
return css `
|
|
25
17
|
label {
|
|
@@ -40,15 +32,18 @@ let Input = class Input extends PapyrosElement {
|
|
|
40
32
|
}
|
|
41
33
|
`;
|
|
42
34
|
}
|
|
35
|
+
get mode() {
|
|
36
|
+
return this.papyros.io.inputMode;
|
|
37
|
+
}
|
|
43
38
|
get otherMode() {
|
|
44
39
|
return this.mode === InputMode.batch ? InputMode.interactive : InputMode.batch;
|
|
45
40
|
}
|
|
46
41
|
toggleMode() {
|
|
47
|
-
this.
|
|
42
|
+
this.papyros.io.inputMode = this.otherMode;
|
|
48
43
|
}
|
|
49
44
|
render() {
|
|
50
45
|
if (this.papyros.debugger.active) {
|
|
51
|
-
this.
|
|
46
|
+
this.papyros.io.inputMode = InputMode.batch;
|
|
52
47
|
}
|
|
53
48
|
return html `
|
|
54
49
|
${this.mode === InputMode.batch ?
|
|
@@ -63,9 +58,6 @@ let Input = class Input extends PapyrosElement {
|
|
|
63
58
|
`;
|
|
64
59
|
}
|
|
65
60
|
};
|
|
66
|
-
__decorate([
|
|
67
|
-
property({ state: true })
|
|
68
|
-
], Input.prototype, "mode", void 0);
|
|
69
61
|
Input = __decorate([
|
|
70
62
|
customElement("p-input")
|
|
71
63
|
], Input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/frontend/components/Input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/frontend/components/Input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAa,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3D,OAAO,oBAAoB,CAAC;AAC5B,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG1C,IAAM,KAAK,GAAX,MAAM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irror/BatchInputEditor";
|
|
3
3
|
import { PapyrosElement } from "../PapyrosElement";
|
|
4
4
|
export declare class BatchInput extends PapyrosElement {
|
|
5
|
-
buffer: string;
|
|
6
|
-
unsubscribe: () => void;
|
|
7
5
|
static get styles(): CSSResult;
|
|
8
6
|
get usedLines(): number | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* All lines except the last one that has not (yet) been terminated by a newline
|
|
11
|
-
*/
|
|
12
|
-
get lines(): string[];
|
|
13
|
-
get nextLine(): string | undefined;
|
|
14
7
|
get placeholder(): string;
|
|
15
|
-
connectedCallback(): void;
|
|
16
|
-
disconnectedCallback(): void;
|
|
17
|
-
provideInput(): void;
|
|
18
8
|
protected render(): TemplateResult;
|
|
19
9
|
}
|
|
@@ -4,17 +4,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { customElement
|
|
7
|
+
import { customElement } from "lit/decorators.js";
|
|
8
8
|
import { css, html } from "lit";
|
|
9
9
|
import "../code_mirror/BatchInputEditor";
|
|
10
10
|
import { RunState } from "../../state/Runner";
|
|
11
11
|
import { PapyrosElement } from "../PapyrosElement";
|
|
12
12
|
let BatchInput = class BatchInput extends PapyrosElement {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.buffer = "";
|
|
16
|
-
this.unsubscribe = () => { };
|
|
17
|
-
}
|
|
18
13
|
static get styles() {
|
|
19
14
|
return css `
|
|
20
15
|
:host {
|
|
@@ -31,60 +26,26 @@ let BatchInput = class BatchInput extends PapyrosElement {
|
|
|
31
26
|
}
|
|
32
27
|
return this.papyros.io.inputs.length;
|
|
33
28
|
}
|
|
34
|
-
/**
|
|
35
|
-
* All lines except the last one that has not (yet) been terminated by a newline
|
|
36
|
-
*/
|
|
37
|
-
get lines() {
|
|
38
|
-
return this.buffer.split("\n").slice(0, -1);
|
|
39
|
-
}
|
|
40
|
-
get nextLine() {
|
|
41
|
-
if (this.usedLines !== undefined && this.lines.length > this.usedLines) {
|
|
42
|
-
return this.lines[this.usedLines];
|
|
43
|
-
}
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
29
|
get placeholder() {
|
|
47
30
|
if (this.papyros.io.prompt) {
|
|
48
31
|
return this.papyros.io.prompt;
|
|
49
32
|
}
|
|
50
33
|
return this.t("Papyros.input_placeholder.batch");
|
|
51
34
|
}
|
|
52
|
-
connectedCallback() {
|
|
53
|
-
super.connectedCallback();
|
|
54
|
-
this.unsubscribe = this.papyros.io.subscribe(() => this.provideInput(), "awaitingInput");
|
|
55
|
-
}
|
|
56
|
-
disconnectedCallback() {
|
|
57
|
-
super.disconnectedCallback();
|
|
58
|
-
this.unsubscribe();
|
|
59
|
-
}
|
|
60
|
-
provideInput() {
|
|
61
|
-
if (this.papyros.io.awaitingInput && this.nextLine !== undefined) {
|
|
62
|
-
this.papyros.io.provideInput(this.nextLine);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
35
|
render() {
|
|
66
36
|
return html `
|
|
67
37
|
<p-batch-input-editor
|
|
68
|
-
.value=${this.
|
|
38
|
+
.value=${this.papyros.io.inputBuffer}
|
|
69
39
|
.usedLines=${this.usedLines}
|
|
70
40
|
.readOnly=${this.papyros.debugger.active && this.papyros.runner.state === RunState.Ready}
|
|
71
41
|
.placeholder=${this.placeholder}
|
|
72
42
|
.translations=${this.papyros.i18n.getTranslations("CodeMirror")}
|
|
73
43
|
.theme=${this.papyros.constants.CodeMirrorTheme}
|
|
74
|
-
@change=${(e) =>
|
|
75
|
-
this.buffer = e.detail;
|
|
76
|
-
this.provideInput();
|
|
77
|
-
if (!this.papyros.debugger.active && this.papyros.runner.state === RunState.Ready) {
|
|
78
|
-
this.papyros.io.clearInputs();
|
|
79
|
-
}
|
|
80
|
-
}}
|
|
44
|
+
@change=${(e) => this.papyros.io.inputBuffer = e.detail}
|
|
81
45
|
></p-batch-input-editor>
|
|
82
46
|
`;
|
|
83
47
|
}
|
|
84
48
|
};
|
|
85
|
-
__decorate([
|
|
86
|
-
property({ state: true })
|
|
87
|
-
], BatchInput.prototype, "buffer", void 0);
|
|
88
49
|
BatchInput = __decorate([
|
|
89
50
|
customElement("p-batch-input")
|
|
90
51
|
], BatchInput);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BatchInput.js","sourceRoot":"","sources":["../../../../src/frontend/components/input/BatchInput.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"BatchInput.js","sourceRoot":"","sources":["../../../../src/frontend/components/input/BatchInput.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAa,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3D,OAAO,iCAAiC,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG5C,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,cAAc;IAC1C,MAAM,KAAK,MAAM;QACb,OAAO,GAAG,CAAA;;;;;;;SAOT,CAAC;IACN,CAAC;IAED,IAAI,SAAS;QACT,IAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACrF,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC;QACjD,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;IACzC,CAAC;IAED,IAAI,WAAW;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contentType?: string;
|
|
41
41
|
};
|
|
42
|
+
export declare enum InputMode {
|
|
43
|
+
batch = "batch",
|
|
44
|
+
interactive = "interactive"
|
|
45
|
+
}
|
|
42
46
|
export declare class InputOutput extends State {
|
|
43
47
|
private papyros;
|
|
44
48
|
inputs: string[];
|
|
45
49
|
output: OutputEntry[];
|
|
46
50
|
prompt: string;
|
|
47
51
|
awaitingInput: boolean;
|
|
52
|
+
inputMode: InputMode;
|
|
53
|
+
private _inputBuffer;
|
|
54
|
+
get inputBuffer(): string;
|
|
55
|
+
set inputBuffer(value: string);
|
|
56
|
+
private get nextBufferedLine();
|
|
48
57
|
constructor(papyros: Papyros);
|
|
49
58
|
logError(error: FriendlyError | string): void;
|
|
50
59
|
logImage(imageData: string, contentType?: string): void;
|
|
@@ -8,19 +8,46 @@ import { State, stateProperty } from "@dodona/lit-state";
|
|
|
8
8
|
import { BackendManager } from "../../communication/BackendManager";
|
|
9
9
|
import { BackendEventType } from "../../communication/BackendEvent";
|
|
10
10
|
import { parseData } from "../../util/Util";
|
|
11
|
+
import { RunState } from "./Runner";
|
|
11
12
|
export var OutputType;
|
|
12
13
|
(function (OutputType) {
|
|
13
14
|
OutputType["stdout"] = "stdout";
|
|
14
15
|
OutputType["stderr"] = "stderr";
|
|
15
16
|
OutputType["img"] = "img";
|
|
16
17
|
})(OutputType || (OutputType = {}));
|
|
18
|
+
export var InputMode;
|
|
19
|
+
(function (InputMode) {
|
|
20
|
+
InputMode["batch"] = "batch";
|
|
21
|
+
InputMode["interactive"] = "interactive";
|
|
22
|
+
})(InputMode || (InputMode = {}));
|
|
17
23
|
export class InputOutput extends State {
|
|
24
|
+
get inputBuffer() {
|
|
25
|
+
return this._inputBuffer;
|
|
26
|
+
}
|
|
27
|
+
set inputBuffer(value) {
|
|
28
|
+
this._inputBuffer = value;
|
|
29
|
+
if (this.nextBufferedLine !== undefined && this.inputMode === InputMode.batch && this.awaitingInput) {
|
|
30
|
+
this.provideInput(this.nextBufferedLine);
|
|
31
|
+
}
|
|
32
|
+
if (!this.papyros.debugger.active && this.papyros.runner.state === RunState.Ready) {
|
|
33
|
+
this.clearInputs();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
get nextBufferedLine() {
|
|
37
|
+
const bufferedLines = this.inputBuffer.split("\n").slice(0, -1);
|
|
38
|
+
if (bufferedLines.length > this.inputs.length) {
|
|
39
|
+
return bufferedLines[this.inputs.length];
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
18
43
|
constructor(papyros) {
|
|
19
44
|
super();
|
|
20
45
|
this.inputs = [];
|
|
21
46
|
this.output = [];
|
|
22
47
|
this.prompt = "";
|
|
23
48
|
this.awaitingInput = false;
|
|
49
|
+
this.inputMode = InputMode.interactive;
|
|
50
|
+
this._inputBuffer = "";
|
|
24
51
|
this.papyros = papyros;
|
|
25
52
|
this.reset();
|
|
26
53
|
BackendManager.subscribe(BackendEventType.Start, () => this.reset());
|
|
@@ -38,6 +65,10 @@ export class InputOutput extends State {
|
|
|
38
65
|
this.logError(data);
|
|
39
66
|
});
|
|
40
67
|
BackendManager.subscribe(BackendEventType.Input, e => {
|
|
68
|
+
if (this.nextBufferedLine !== undefined && this.inputMode === InputMode.batch) {
|
|
69
|
+
this.provideInput(this.nextBufferedLine);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
41
72
|
this.prompt = e.data || "";
|
|
42
73
|
this.awaitingInput = true;
|
|
43
74
|
});
|
|
@@ -90,4 +121,13 @@ __decorate([
|
|
|
90
121
|
__decorate([
|
|
91
122
|
stateProperty
|
|
92
123
|
], InputOutput.prototype, "awaitingInput", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
stateProperty
|
|
126
|
+
], InputOutput.prototype, "inputMode", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
stateProperty
|
|
129
|
+
], InputOutput.prototype, "_inputBuffer", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
stateProperty
|
|
132
|
+
], InputOutput.prototype, "inputBuffer", null);
|
|
93
133
|
//# sourceMappingURL=InputOutput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputOutput.js","sourceRoot":"","sources":["../../../src/frontend/state/InputOutput.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"InputOutput.js","sourceRoot":"","sources":["../../../src/frontend/state/InputOutput.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgCpC,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,yBAAW,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAQD,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,wCAA2B,CAAA;AAC/B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,OAAO,WAAY,SAAQ,KAAK;IAgBlC,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAI,WAAW,CAAC,KAAa;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAG,IAAI,CAAC,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IAEM,WAAW;QACd,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC/B,CAAC;CACJ;AApGO;IADH,aAAa;2CACY;AAEtB;IADH,aAAa;2CACiB;AAE3B;IADH,aAAa;2CACU;AAEpB;IADH,aAAa;kDACqB;AAE/B;IADH,aAAa;8CACmC;AAGzC;IADP,aAAa;iDACoB;AAElC;IADC,aAAa;8CAGb"}
|
package/dist/util/Util.d.ts
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper type to access a HTML element, either via its id or the element itself
|
|
3
|
-
*/
|
|
4
|
-
type ElementIdentifier = string | HTMLElement;
|
|
5
|
-
/**
|
|
6
|
-
* Resolve an ElementIdentifier to the corresponding HTLMElement
|
|
7
|
-
* @param {ElementIdentifier} elementId The identifier for the element
|
|
8
|
-
* @return {T} The corresponding element
|
|
9
|
-
*/
|
|
10
|
-
export declare function getElement<T extends HTMLElement>(elementId: ElementIdentifier): T;
|
|
11
|
-
/**
|
|
12
|
-
* Add a listener to an HTML element for an event on an attribute
|
|
13
|
-
* Element attributes tend to be strings, but string Enums can also be used
|
|
14
|
-
* by using the type-parameter T
|
|
15
|
-
* @param {ElementIdentifier} elementId Identifier for the element
|
|
16
|
-
* @param {function(T)} onEvent The listener for the event
|
|
17
|
-
* @param {string} eventType The type of the event
|
|
18
|
-
* @param {string} attribute The attribute affected by the event
|
|
19
|
-
*/
|
|
20
|
-
export declare function addListener<T extends string>(elementId: ElementIdentifier, onEvent: (e: T) => void, eventType?: string, attribute?: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Unset the selected item of a select element to prevent a default selection
|
|
23
|
-
* @param {ElementIdentifier} selectId Identifier for the select element
|
|
24
|
-
*/
|
|
25
|
-
export declare function removeSelection(selectId: string): void;
|
|
26
1
|
/**
|
|
27
2
|
* Parse the data contained within a PapyrosEvent using its contentType
|
|
28
3
|
* Supported content types are: text/plain, text/json, img/png;base64
|
|
@@ -31,18 +6,3 @@ export declare function removeSelection(selectId: string): void;
|
|
|
31
6
|
* @return {any} The parsed data
|
|
32
7
|
*/
|
|
33
8
|
export declare function parseData(data: string, contentType?: string): any;
|
|
34
|
-
export declare function downloadResults(data: string, filename: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Obtain the url of the current page without hashes, identifiers, query params, ...
|
|
37
|
-
* @param {boolean} endingSlash Whether the url should end in a slash
|
|
38
|
-
* @return {string} The current url
|
|
39
|
-
*/
|
|
40
|
-
export declare function cleanCurrentUrl(endingSlash?: boolean): string;
|
|
41
|
-
/**
|
|
42
|
-
* Focus an element, setting the user's caret at the end of the contents
|
|
43
|
-
* Needed to ensure focusing a contenteditable element works as expected
|
|
44
|
-
* @param {HTMLElement} el The element to focus
|
|
45
|
-
*/
|
|
46
|
-
export declare function placeCaretAtEnd(el: HTMLElement): void;
|
|
47
|
-
export declare function createDelayer(): (callback: () => void, ms: number) => void;
|
|
48
|
-
export {};
|
package/dist/util/Util.js
CHANGED
|
@@ -1,39 +1,4 @@
|
|
|
1
1
|
import { LogType, papyrosLog } from "./Logging";
|
|
2
|
-
/**
|
|
3
|
-
* Resolve an ElementIdentifier to the corresponding HTLMElement
|
|
4
|
-
* @param {ElementIdentifier} elementId The identifier for the element
|
|
5
|
-
* @return {T} The corresponding element
|
|
6
|
-
*/
|
|
7
|
-
export function getElement(elementId) {
|
|
8
|
-
if (typeof elementId === "string") {
|
|
9
|
-
return document.getElementById(elementId);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
return elementId;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Add a listener to an HTML element for an event on an attribute
|
|
17
|
-
* Element attributes tend to be strings, but string Enums can also be used
|
|
18
|
-
* by using the type-parameter T
|
|
19
|
-
* @param {ElementIdentifier} elementId Identifier for the element
|
|
20
|
-
* @param {function(T)} onEvent The listener for the event
|
|
21
|
-
* @param {string} eventType The type of the event
|
|
22
|
-
* @param {string} attribute The attribute affected by the event
|
|
23
|
-
*/
|
|
24
|
-
export function addListener(elementId, onEvent, eventType = "change", attribute = "value") {
|
|
25
|
-
const element = getElement(elementId);
|
|
26
|
-
element.addEventListener(eventType, () => {
|
|
27
|
-
onEvent(element[attribute] || element.getAttribute(attribute));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Unset the selected item of a select element to prevent a default selection
|
|
32
|
-
* @param {ElementIdentifier} selectId Identifier for the select element
|
|
33
|
-
*/
|
|
34
|
-
export function removeSelection(selectId) {
|
|
35
|
-
getElement(selectId).selectedIndex = -1;
|
|
36
|
-
}
|
|
37
2
|
/**
|
|
38
3
|
* Parse the data contained within a PapyrosEvent using its contentType
|
|
39
4
|
* Supported content types are: text/plain, text/json, img/png;base64
|
|
@@ -80,59 +45,4 @@ export function parseData(data, contentType) {
|
|
|
80
45
|
papyrosLog(LogType.Important, `Unhandled content type: ${contentType}`);
|
|
81
46
|
return data;
|
|
82
47
|
}
|
|
83
|
-
export function downloadResults(data, filename) {
|
|
84
|
-
const blob = new Blob([data], { type: "text/plain" });
|
|
85
|
-
const elem = window.document.createElement("a");
|
|
86
|
-
// Cast URL to any as TypeScript doesn't recognize it properly
|
|
87
|
-
// error TS2339: Property 'revokeObjectURL' does not exist on type
|
|
88
|
-
const windowUrl = URL;
|
|
89
|
-
elem.href = windowUrl.createObjectURL(blob);
|
|
90
|
-
elem.download = filename;
|
|
91
|
-
document.body.appendChild(elem);
|
|
92
|
-
elem.click();
|
|
93
|
-
document.body.removeChild(elem);
|
|
94
|
-
windowUrl.revokeObjectURL(elem.href);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Obtain the url of the current page without hashes, identifiers, query params, ...
|
|
98
|
-
* @param {boolean} endingSlash Whether the url should end in a slash
|
|
99
|
-
* @return {string} The current url
|
|
100
|
-
*/
|
|
101
|
-
export function cleanCurrentUrl(endingSlash = false) {
|
|
102
|
-
let url = location.origin + location.pathname;
|
|
103
|
-
if (endingSlash && !url.endsWith("/")) {
|
|
104
|
-
url += "/";
|
|
105
|
-
}
|
|
106
|
-
else if (!endingSlash && url.endsWith("/")) {
|
|
107
|
-
url = url.slice(0, url.length - 1);
|
|
108
|
-
}
|
|
109
|
-
return url;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Focus an element, setting the user's caret at the end of the contents
|
|
113
|
-
* Needed to ensure focusing a contenteditable element works as expected
|
|
114
|
-
* @param {HTMLElement} el The element to focus
|
|
115
|
-
*/
|
|
116
|
-
export function placeCaretAtEnd(el) {
|
|
117
|
-
// Source: https://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browser
|
|
118
|
-
el.focus();
|
|
119
|
-
if (typeof window.getSelection !== "undefined" &&
|
|
120
|
-
typeof document.createRange !== "undefined") {
|
|
121
|
-
const range = document.createRange();
|
|
122
|
-
range.selectNodeContents(el);
|
|
123
|
-
range.collapse(false);
|
|
124
|
-
const sel = window.getSelection();
|
|
125
|
-
if (sel) {
|
|
126
|
-
sel.removeAllRanges();
|
|
127
|
-
sel.addRange(range);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
export function createDelayer() {
|
|
132
|
-
let timer;
|
|
133
|
-
return (callback, ms) => {
|
|
134
|
-
clearTimeout(timer);
|
|
135
|
-
timer = setTimeout(callback, ms);
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
48
|
//# sourceMappingURL=Util.js.map
|
package/dist/util/Util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.js","sourceRoot":"","sources":["../../src/util/Util.ts"],"names":[],"mappings":"AAAA,OAAO,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