spawn-term 1.0.18 → 1.0.20
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/cjs/createApp.js
CHANGED
|
@@ -24,20 +24,21 @@ function createApp() {
|
|
|
24
24
|
var store = null;
|
|
25
25
|
var inkApp = null;
|
|
26
26
|
var previousData = null;
|
|
27
|
-
var rerender = function() {
|
|
27
|
+
var rerender = (0, _lodashthrottle.default)(function() {
|
|
28
28
|
if (!inkApp || !store) return;
|
|
29
29
|
if (store.data() === previousData) return;
|
|
30
30
|
previousData = store.data();
|
|
31
31
|
inkApp.rerender(/*#__PURE__*/ (0, _jsxruntime.jsx)(_Appts.default, {
|
|
32
32
|
store: store
|
|
33
33
|
}));
|
|
34
|
-
}
|
|
35
|
-
|
|
34
|
+
}, THROTTLE, {
|
|
35
|
+
leading: false
|
|
36
|
+
});
|
|
36
37
|
return {
|
|
37
38
|
retain: function retain(fn) {
|
|
38
39
|
if (++refCount > 1) return fn(store);
|
|
39
40
|
if (store) throw new Error('Not expecting store');
|
|
40
|
-
store = new _Storets.default(
|
|
41
|
+
store = new _Storets.default(rerender);
|
|
41
42
|
inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_Appts.default, {
|
|
42
43
|
store: store
|
|
43
44
|
}));
|
|
@@ -46,7 +47,8 @@ function createApp() {
|
|
|
46
47
|
release: function release(cb) {
|
|
47
48
|
if (--refCount > 0) return cb();
|
|
48
49
|
if (!store) throw new Error('Expecting store');
|
|
49
|
-
rerender();
|
|
50
|
+
rerender.flush();
|
|
51
|
+
rerender.cancel();
|
|
50
52
|
inkApp.waitUntilExit().then(function() {
|
|
51
53
|
return cb();
|
|
52
54
|
}).catch(cb);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.ts';\nimport { default as Store, type StoreData } from './state/Store.ts';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.ts';\nimport { default as Store, type StoreData } from './state/Store.ts';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = throttle(\n () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n },\n THROTTLE,\n { leading: false }\n );\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerender);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender.flush();\n rerender.cancel();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["createApp","THROTTLE","refCount","store","inkApp","previousData","rerender","throttle","data","App","leading","retain","fn","Error","Store","render","release","cb","flush","cancel","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";;;;+BAUA;;;eAAwBA;;;;mBAVc;qEACjB;4DACL;8DACiC;;;;;;AAKjD,IAAMC,WAAW;AAEF,SAASD;IACtB,IAAIE,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,IAAMC,WAAWC,IAAAA,uBAAQ,EACvB;QACE,IAAI,CAACH,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMK,IAAI,OAAOH,cAAc;QACnCA,eAAeF,MAAMK,IAAI;QACzBJ,OAAOE,QAAQ,eAAC,qBAACG,cAAG;YAACN,OAAOA;;IAC9B,GACAF,UACA;QAAES,SAAS;IAAM;IAGnB,OAAO;QACLC,QAAAA,SAAAA,OAAOC,EAAkB;YACvB,IAAI,EAAEV,WAAW,GAAG,OAAOU,GAAGT;YAC9B,IAAIA,OAAO,MAAM,IAAIU,MAAM;YAE3BV,QAAQ,IAAIW,gBAAK,CAACR;YAClBF,SAASW,IAAAA,WAAM,gBAAC,qBAACN,cAAG;gBAACN,OAAOA;;YAC5BS,GAAGT;QACL;QACAa,SAAAA,SAAAA,QAAQC,EAAmB;YACzB,IAAI,EAAEf,WAAW,GAAG,OAAOe;YAC3B,IAAI,CAACd,OAAO,MAAM,IAAIU,MAAM;YAE5BP,SAASY,KAAK;YACdZ,SAASa,MAAM;YACff,OACGgB,aAAa,GACbC,IAAI,CAAC;uBAAMJ;eACXK,KAAK,CAACL;YACTb,OAAOmB,OAAO;YACdnB,SAAS;YACTD,QAAQ;YACRqB,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
package/dist/esm/createApp.js
CHANGED
|
@@ -9,20 +9,21 @@ export default function createApp() {
|
|
|
9
9
|
let store = null;
|
|
10
10
|
let inkApp = null;
|
|
11
11
|
let previousData = null;
|
|
12
|
-
const rerender = ()=>{
|
|
12
|
+
const rerender = throttle(()=>{
|
|
13
13
|
if (!inkApp || !store) return;
|
|
14
14
|
if (store.data() === previousData) return;
|
|
15
15
|
previousData = store.data();
|
|
16
16
|
inkApp.rerender(/*#__PURE__*/ _jsx(App, {
|
|
17
17
|
store: store
|
|
18
18
|
}));
|
|
19
|
-
}
|
|
20
|
-
|
|
19
|
+
}, THROTTLE, {
|
|
20
|
+
leading: false
|
|
21
|
+
});
|
|
21
22
|
return {
|
|
22
23
|
retain (fn) {
|
|
23
24
|
if (++refCount > 1) return fn(store);
|
|
24
25
|
if (store) throw new Error('Not expecting store');
|
|
25
|
-
store = new Store(
|
|
26
|
+
store = new Store(rerender);
|
|
26
27
|
inkApp = render(/*#__PURE__*/ _jsx(App, {
|
|
27
28
|
store: store
|
|
28
29
|
}));
|
|
@@ -31,7 +32,8 @@ export default function createApp() {
|
|
|
31
32
|
release (cb) {
|
|
32
33
|
if (--refCount > 0) return cb();
|
|
33
34
|
if (!store) throw new Error('Expecting store');
|
|
34
|
-
rerender();
|
|
35
|
+
rerender.flush();
|
|
36
|
+
rerender.cancel();
|
|
35
37
|
inkApp.waitUntilExit().then(()=>cb()).catch(cb);
|
|
36
38
|
inkApp.unmount();
|
|
37
39
|
inkApp = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.ts';\nimport { default as Store, type StoreData } from './state/Store.ts';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.ts';\nimport { default as Store, type StoreData } from './state/Store.ts';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = throttle(\n () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n },\n THROTTLE,\n { leading: false }\n );\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerender);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender.flush();\n rerender.cancel();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["render","throttle","App","default","Store","THROTTLE","createApp","refCount","store","inkApp","previousData","rerender","data","leading","retain","fn","Error","release","cb","flush","cancel","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,SAAS,sBAAsB;AACtC,SAASC,WAAWC,KAAK,QAAwB,mBAAmB;AAKpE,MAAMC,WAAW;AAEjB,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,MAAMC,WAAWV,SACf;QACE,IAAI,CAACQ,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,KAACT;YAAIM,OAAOA;;IAC9B,GACAH,UACA;QAAEQ,SAAS;IAAM;IAGnB,OAAO;QACLC,QAAOC,EAAkB;YACvB,IAAI,EAAER,WAAW,GAAG,OAAOQ,GAAGP;YAC9B,IAAIA,OAAO,MAAM,IAAIQ,MAAM;YAE3BR,QAAQ,IAAIJ,MAAMO;YAClBF,SAAST,qBAAO,KAACE;gBAAIM,OAAOA;;YAC5BO,GAAGP;QACL;QACAS,SAAQC,EAAmB;YACzB,IAAI,EAAEX,WAAW,GAAG,OAAOW;YAC3B,IAAI,CAACV,OAAO,MAAM,IAAIQ,MAAM;YAE5BL,SAASQ,KAAK;YACdR,SAASS,MAAM;YACfX,OACGY,aAAa,GACbC,IAAI,CAAC,IAAMJ,MACXK,KAAK,CAACL;YACTT,OAAOe,OAAO;YACdf,SAAS;YACTD,QAAQ;YACRiB,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spawn-term",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"version": "tsds version"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"cross-spawn-cb": "^2.3.
|
|
43
|
+
"cross-spawn-cb": "^2.3.10",
|
|
44
44
|
"ink": "^6.0.1",
|
|
45
45
|
"lodash.throttle": "^4.1.1",
|
|
46
46
|
"on-one": "^1.0.1",
|