@jsenv/terminal-recorder 1.5.45 → 1.5.47

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.
Files changed (26) hide show
  1. package/dist/jsenv_terminal_recorder_node_modules.js +14 -22
  2. package/dist/terminal_recorder_browser.js +135 -52
  3. package/package.json +6 -6
  4. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/addon-fit/lib/addon-fit.mjs +18 -0
  5. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/addon-fit/lib/addon-fit.mjs.map +28 -0
  6. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/addon-serialize/lib/addon-serialize.mjs +19 -0
  7. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/addon-serialize/lib/addon-serialize.mjs.map +176 -0
  8. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/addon-webgl/lib/addon-webgl.mjs +101 -0
  9. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/addon-webgl/lib/addon-webgl.mjs.map +1623 -0
  10. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/xterm/css/xterm.css +267 -0
  11. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/xterm/lib/xterm.mjs +53 -0
  12. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/node_modules/@xterm/xterm/lib/xterm.mjs.map +3592 -0
  13. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/packages/backend/server/src/plugins/autoreload_on_server_restart/client/autoreload_on_server_restart.js +133 -0
  14. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/packages/frontend/custom-elements-redefine/src/main.js +217 -0
  15. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/packages/internal/plugin-supervisor/src/client/supervisor.js +1418 -0
  16. package/src/.jsenv/chrome@145.0.0/@fs/Users/dmail/Documents/dev/jsenv/core/src/plugins/drop_to_open/client/drop_to_open.js +49 -0
  17. package/src/.jsenv/chrome@145.0.0/gif_encoder.js +400 -0
  18. package/src/.jsenv/chrome@145.0.0/gif_encoder.js.map +11 -0
  19. package/src/.jsenv/chrome@145.0.0/lzw_encoder.js +253 -0
  20. package/src/.jsenv/chrome@145.0.0/neuquant.js +498 -0
  21. package/src/.jsenv/chrome@145.0.0/terminal_recorder.js +384 -0
  22. package/src/.jsenv/chrome@145.0.0/terminal_recorder.js.map +11 -0
  23. package/src/.jsenv/chrome@145.0.0/xterm.html +64 -0
  24. package/src/.jsenv/chrome@145.0.0/xterm.html@L14C5-L18C14.js +5 -0
  25. package/src/.jsenv/chrome@145.0.0/xterm.html@L19C5-L24C14.js +7 -0
  26. package/src/.jsenv/chrome@145.0.0/xterm.html@L19C5-L24C14.js.map +11 -0
@@ -0,0 +1,133 @@
1
+ const css = /* css */ `
2
+ dialog {
3
+ opacity: 0;
4
+ transition: all 0.3s allow-discrete;
5
+ }
6
+ dialog::backdrop {
7
+ background-image: linear-gradient(
8
+ 45deg,
9
+ magenta,
10
+ rebeccapurple,
11
+ dodgerblue,
12
+ green
13
+ );
14
+ opacity: 0;
15
+ transition: all 0.3s allow-discrete;
16
+ }
17
+ dialog:open {
18
+ opacity: 1;
19
+ }
20
+ dialog:open::backdrop {
21
+ opacity: 0.75;
22
+ }
23
+ `;
24
+
25
+ const html = /* html */ `<style>
26
+ ${css}
27
+ </style>
28
+ <dialog>
29
+ <p>Connection with server is lost</p>
30
+ <button autofocus name="reconnect">Retry</button>
31
+ </dialog>`;
32
+
33
+ class JsenvAutoreloadOnServerRestart extends HTMLElement {
34
+ constructor({ url } = {}) {
35
+ super();
36
+ const root = this.attachShadow({ mode: "open" });
37
+ root.innerHTML = html;
38
+
39
+ const dialog = root.querySelector("dialog");
40
+ const reconnectButton = dialog.querySelector('button[name="reconnect"]');
41
+
42
+ (async () => {
43
+ const connect = () => {
44
+ const websocket = new WebSocket(url);
45
+ const connectedPromise = new Promise((resolve) => {
46
+ websocket.onerror = () => {
47
+ resolve(null);
48
+ };
49
+ websocket.onopen = () => {
50
+ resolve(websocket);
51
+ };
52
+ });
53
+ return connectedPromise;
54
+ };
55
+
56
+ const initialWebSocket = await connect();
57
+ if (!initialWebSocket) {
58
+ return;
59
+ }
60
+ initialWebSocket.onclose = async () => {
61
+ console.info("connection to server lost, trying to reconnect");
62
+ const retry = async () => {
63
+ let attemptCount = 0;
64
+ let timeToWait = 100;
65
+ const tryToReconnect = async () => {
66
+ const newWebsocket = await connect();
67
+ if (newWebsocket) {
68
+ dialog.close();
69
+ console.info("reconnected to server, reloading the page...");
70
+ window.location.reload(true);
71
+ return;
72
+ }
73
+ attemptCount++;
74
+ if (attemptCount === 10) {
75
+ dialog.showModal();
76
+ reconnectButton.onclick = async () => {
77
+ reconnectButton.disabled = true;
78
+ const previousContext = reconnectButton.textContent;
79
+ reconnectButton.textContent = "Retrying...";
80
+ await retry();
81
+ reconnectButton.textContent = previousContext;
82
+ reconnectButton.disabled = false;
83
+ };
84
+ return;
85
+ }
86
+ timeToWait += 100;
87
+ await new Promise((resolve) => setTimeout(resolve, timeToWait));
88
+ await tryToReconnect();
89
+ };
90
+ await tryToReconnect();
91
+ };
92
+ retry();
93
+ };
94
+ })();
95
+ }
96
+ }
97
+ if (!customElements.get("jsenv-autoreload-on-server-restart")) {
98
+ customElements.define(
99
+ "jsenv-autoreload-on-server-restart",
100
+ JsenvAutoreloadOnServerRestart,
101
+ );
102
+ }
103
+
104
+ const websocketEndpoint =
105
+ document.currentScript.getAttribute("data-ws-endpoint") ||
106
+ "/.internal/alive.websocket";
107
+
108
+ const jsenvAutoreloadOnServerRestartElement =
109
+ new JsenvAutoreloadOnServerRestart({
110
+ url: (() => {
111
+ const websocketScheme =
112
+ self.location.protocol === "https:" ? "wss" : "ws";
113
+ const websocketUrl = `${websocketScheme}://${self.location.host}${websocketEndpoint}`;
114
+ return websocketUrl;
115
+ })(),
116
+ });
117
+
118
+ // script is injected into document.body
119
+ if (document.body) {
120
+ document.currentScript.parentNode.replaceChild(
121
+ jsenvAutoreloadOnServerRestartElement,
122
+ document.currentScript,
123
+ );
124
+ }
125
+ // script injected outisde document.body (likely in head)
126
+ else {
127
+ document.currentScript.parentNode.removeChild(document.currentScript);
128
+ document.onreadystatechange = () => {
129
+ if (document.readyState === "interactive") {
130
+ document.body.appendChild(jsenvAutoreloadOnServerRestartElement);
131
+ }
132
+ };
133
+ }
@@ -0,0 +1,217 @@
1
+ /*
2
+ * https://github.com/lit/lit/issues/1844
3
+ * https://github.com/vegarringdal/custom-elements-hmr-polyfill/tree/master
4
+ */
5
+
6
+ export const allowCustomElementsRedefine = ({
7
+ updateWholeDOMOnRedefine = false,
8
+ } = {}) => {
9
+ const patchedSymbol = Symbol.for("allowCustomElementsRedefine");
10
+ if (customElements.define[patchedSymbol]) {
11
+ customElements.define[patchedSymbol].updateWholeDOMOnRedefine =
12
+ updateWholeDOMOnRedefine;
13
+ return;
14
+ }
15
+ const elementsChanged = [];
16
+ let timeoutId;
17
+ const onCustomElementChange = (
18
+ customElementName,
19
+ // customElementClass,
20
+ // options,
21
+ ) => {
22
+ if (!customElements.define[patchedSymbol].updateWholeDOMOnRedefine) {
23
+ return;
24
+ }
25
+ elementsChanged.push(customElementName);
26
+ clearTimeout(timeoutId);
27
+ timeoutId = setTimeout(() => {
28
+ if (document.body) {
29
+ requestAnimationFrame(() => {
30
+ // re-render the whole DOM
31
+ // this will make less calls to connectedCallback/disconnectedCallback on replaced child node when created.
32
+ const oldBodyHtml = document.body.innerHTML;
33
+ document.body.innerHTML = "";
34
+ document.body.innerHTML = oldBodyHtml;
35
+ });
36
+ }
37
+ elementsChanged.length = 0;
38
+ }, 250);
39
+ };
40
+
41
+ const customElementClassMap = new Map();
42
+ const defineOriginal = customElements.define;
43
+ const definePatched = (customElementName, customElementClass, options) => {
44
+ const registeredCustomElement = customElements.get(customElementName);
45
+ customElementClassMap.set(customElementName, customElementClass);
46
+ if (registeredCustomElement) {
47
+ onCustomElementChange(customElementName, customElementClass, options);
48
+ return;
49
+ }
50
+ const CustomElementFacade = createCustomElementFacade(
51
+ customElementName,
52
+ customElementClass,
53
+ );
54
+ defineOriginal.call(
55
+ customElements,
56
+ customElementName,
57
+ CustomElementFacade,
58
+ options,
59
+ );
60
+ };
61
+ definePatched[patchedSymbol] = { updateWholeDOMOnRedefine };
62
+ customElements.define = definePatched;
63
+
64
+ const observerSymbol = Symbol.for("observedAttributesObserver");
65
+ const createCustomElementFacade = (
66
+ customElementName,
67
+ customElementFirstClass,
68
+ ) => {
69
+ class CustomElementFacade extends customElementFirstClass {
70
+ static get observedAttributes() {
71
+ return [];
72
+ }
73
+
74
+ constructor(...args) {
75
+ const CustomElementClass = customElementClassMap.get(customElementName);
76
+
77
+ if (CustomElementClass !== customElementFirstClass) {
78
+ update_prototype_chain: {
79
+ let ClassCandidate = CustomElementClass;
80
+ while (ClassCandidate) {
81
+ const nextClassCandidate = Object.getPrototypeOf(ClassCandidate);
82
+ if (!nextClassCandidate) {
83
+ break;
84
+ }
85
+ const name = nextClassCandidate.name;
86
+ if (name) {
87
+ const constructor = window[name];
88
+ if (constructor && constructor.prototype instanceof Element) {
89
+ patchProperties(
90
+ CustomElementFacade.prototype,
91
+ ClassCandidate.prototype,
92
+ );
93
+ break;
94
+ }
95
+ }
96
+ ClassCandidate = nextClassCandidate;
97
+ }
98
+ }
99
+ update_prototype: {
100
+ const CustomElementPrototype = CustomElementClass.prototype;
101
+ patchProperties(
102
+ CustomElementFacade.prototype,
103
+ CustomElementPrototype,
104
+ );
105
+ }
106
+ }
107
+ const customElementInstance = Reflect.construct(
108
+ CustomElementClass,
109
+ args,
110
+ CustomElementFacade,
111
+ );
112
+ // eslint-disable-next-line no-constructor-return
113
+ return customElementInstance;
114
+ }
115
+
116
+ connectedCallback(...args) {
117
+ const CustomElementClass = customElementClassMap.get(customElementName);
118
+ const CustomElementPrototype = CustomElementClass.prototype;
119
+ const observedAttributes = CustomElementClass.observedAttributes;
120
+
121
+ // call initial callback when class is created
122
+ if (observedAttributes) {
123
+ if (Array.isArray(observedAttributes)) {
124
+ observedAttributes.forEach((observedAttributeName) => {
125
+ const haveAtt = this.getAttributeNode(observedAttributeName);
126
+ if (haveAtt) {
127
+ CustomElementPrototype.attributeChangedCallback.call(
128
+ this,
129
+ observedAttributeName,
130
+ null,
131
+ this.getAttribute(observedAttributeName),
132
+ null,
133
+ );
134
+ }
135
+ });
136
+ } else {
137
+ console.warn(
138
+ `observedAttributes in ${customElementName} is not array, please fix`,
139
+ );
140
+ }
141
+ }
142
+ const mutationObserver = new MutationObserver((mutationList) => {
143
+ mutationList.forEach((mutation) => {
144
+ if (
145
+ CustomElementPrototype.attributeChangedCallback &&
146
+ observedAttributes &&
147
+ observedAttributes.includes(mutation.attributeName)
148
+ ) {
149
+ CustomElementPrototype.attributeChangedCallback.call(
150
+ this,
151
+ mutation.attributeName,
152
+ mutation.oldValue,
153
+ this.getAttribute(mutation.attributeName),
154
+ null,
155
+ );
156
+ }
157
+ });
158
+ });
159
+ this[observerSymbol] = mutationObserver;
160
+ mutationObserver.observe(this, {
161
+ childList: false,
162
+ attributes: true,
163
+ attributeOldValue: true,
164
+ subtree: false,
165
+ });
166
+
167
+ if (CustomElementPrototype.connectedCallback) {
168
+ CustomElementPrototype.connectedCallback.call(this, ...args);
169
+ }
170
+ }
171
+
172
+ disconnectedCallback(...args) {
173
+ this[observerSymbol].disconnect();
174
+ this[observerSymbol] = null;
175
+
176
+ const CustomElementClass = customElementClassMap.get(customElementName);
177
+ const CustomElementPrototype = CustomElementClass.prototype;
178
+ if (CustomElementPrototype.disconnectedCallback) {
179
+ CustomElementPrototype.disconnectedCallback.call(this, ...args);
180
+ }
181
+ }
182
+
183
+ adoptedCallback(...args) {
184
+ const CustomElementClass = customElementClassMap.get(customElementName);
185
+ const CustomElementPrototype = CustomElementClass.prototype;
186
+ if (CustomElementPrototype.adoptedCallback) {
187
+ CustomElementPrototype.adoptedCallback.call(this, ...args);
188
+ }
189
+ }
190
+ }
191
+ return CustomElementFacade;
192
+ };
193
+ const patchProperties = (into, from) => {
194
+ const ownPropertyNames = Object.getOwnPropertyNames(from);
195
+ ownPropertyNames.forEach((ownPropertyName) => {
196
+ if (PROPERTY_NAMES_TO_SKIP.includes(ownPropertyName)) {
197
+ return;
198
+ }
199
+ const propertyDescriptor = Object.getOwnPropertyDescriptor(
200
+ from,
201
+ ownPropertyName,
202
+ );
203
+ if (!propertyDescriptor) {
204
+ return;
205
+ }
206
+ if (!propertyDescriptor.configurable) {
207
+ console.warn(
208
+ "[custom-elements-redefined]",
209
+ `${ownPropertyName} is not configurable, skipping`,
210
+ );
211
+ return;
212
+ }
213
+ Object.defineProperty(into, ownPropertyName, propertyDescriptor);
214
+ });
215
+ };
216
+ const PROPERTY_NAMES_TO_SKIP = ["name", "prototype", "length"];
217
+ };