piral-update 0.15.0-alpha.3548 → 0.15.0-alpha.3589
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/esm/actions.d.ts +2 -2
- package/esm/actions.js +10 -35
- package/esm/actions.js.map +1 -1
- package/esm/components.d.ts +2 -2
- package/esm/components.js.map +1 -1
- package/esm/default.d.ts +2 -2
- package/esm/default.js.map +1 -1
- package/esm/types.d.ts +5 -5
- package/lib/actions.d.ts +2 -2
- package/lib/actions.js +10 -35
- package/lib/actions.js.map +1 -1
- package/lib/components.d.ts +2 -2
- package/lib/components.js.map +1 -1
- package/lib/default.d.ts +2 -2
- package/lib/default.js.map +1 -1
- package/lib/types.d.ts +5 -5
- package/package.json +11 -8
- package/piral-update.min.js +1 -0
- package/src/actions.ts +14 -34
- package/src/components.tsx +2 -2
- package/src/default.tsx +2 -2
- package/src/types.ts +5 -5
package/esm/actions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GlobalStateContext,
|
|
1
|
+
import { GlobalStateContext, PiletEntries } from 'piral-core';
|
|
2
2
|
import { PiletUpdateMode } from './types';
|
|
3
3
|
export declare function rejectUpdate(ctx: GlobalStateContext): void;
|
|
4
4
|
export declare function approveUpdate(ctx: GlobalStateContext): void;
|
|
5
|
-
export declare function checkForUpdates(ctx: GlobalStateContext, pilets:
|
|
5
|
+
export declare function checkForUpdates(ctx: GlobalStateContext, pilets: PiletEntries): void;
|
|
6
6
|
export declare function setUpdateMode(ctx: GlobalStateContext, piletName: string, mode: PiletUpdateMode): void;
|
package/esm/actions.js
CHANGED
|
@@ -1,48 +1,23 @@
|
|
|
1
|
-
import { runPilet } from 'piral-base';
|
|
2
1
|
import { withKey } from 'piral-core';
|
|
3
2
|
function getPiletHash(pilet) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
name: pilet.name || '',
|
|
13
|
-
hash: pilet.hash || '',
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
else if ('version' in pilet) {
|
|
17
|
-
return {
|
|
18
|
-
name: pilet.name || '',
|
|
19
|
-
version: pilet.version || '',
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return {
|
|
24
|
-
name: pilet['name'] || '',
|
|
25
|
-
};
|
|
26
|
-
}
|
|
3
|
+
return {
|
|
4
|
+
name: pilet.name,
|
|
5
|
+
version: pilet.version,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function sortPilets(a, b) {
|
|
9
|
+
return a.name.localeCompare(b.name);
|
|
27
10
|
}
|
|
28
11
|
function computePiletHash(pilets) {
|
|
29
|
-
return JSON.stringify(pilets.map(getPiletHash).sort(
|
|
12
|
+
return JSON.stringify(pilets.map(getPiletHash).sort(sortPilets));
|
|
30
13
|
}
|
|
31
14
|
export function rejectUpdate(ctx) {
|
|
32
15
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { updatability: Object.assign(Object.assign({}, state.updatability), { target: [], active: false }) })));
|
|
33
16
|
}
|
|
34
17
|
export function approveUpdate(ctx) {
|
|
35
18
|
const pilets = ctx.readState((s) => s.updatability.target);
|
|
36
|
-
for (const
|
|
37
|
-
ctx.
|
|
38
|
-
try {
|
|
39
|
-
ctx.injectPilet(pilet);
|
|
40
|
-
runPilet(ctx.options.createApi, pilet, ctx.options.hooks);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error(error);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
19
|
+
for (const pilet of pilets) {
|
|
20
|
+
ctx.addPilet(pilet);
|
|
46
21
|
}
|
|
47
22
|
ctx.rejectUpdate();
|
|
48
23
|
}
|
package/esm/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mapp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E,IAAqB;IAC7F,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,YAAY,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,OAEzE,CAAC,CAAC;AACN,CAAC"}
|
package/esm/components.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
2
|
import { UpdateDialogProps } from './types';
|
|
3
|
-
export declare const PiralUpdateDialog:
|
|
3
|
+
export declare const PiralUpdateDialog: ComponentType<UpdateDialogProps>;
|
package/esm/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,MAAM,CAAC,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,MAAM,CAAC,MAAM,iBAAiB,GAAqC,iBAAiB,CAAC,cAAc,CAAC,CAAC"}
|
package/esm/default.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { UpdateDialogProps } from './types';
|
|
3
|
-
export declare const DefaultUpdateDialog:
|
|
3
|
+
export declare const DefaultUpdateDialog: FC<UpdateDialogProps>;
|
package/esm/default.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,CAAC,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,CAAC,MAAM,mBAAmB,GAA0B,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC"}
|
package/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dict, GlobalStateContext,
|
|
1
|
+
import type { Dict, GlobalStateContext, PiletEntries } from 'piral-core';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
declare module 'piral-core/lib/types/custom' {
|
|
4
4
|
interface PiletCustomApi extends PiletUpdateApi {
|
|
@@ -15,7 +15,7 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
15
15
|
interface PiralCustomActions {
|
|
16
16
|
rejectUpdate(): void;
|
|
17
17
|
approveUpdate(): void;
|
|
18
|
-
checkForUpdates(pilets:
|
|
18
|
+
checkForUpdates(pilets: PiletEntries): void;
|
|
19
19
|
setUpdateMode(piletName: string, mode: PiletUpdateMode): void;
|
|
20
20
|
}
|
|
21
21
|
interface PiralCustomComponentsState {
|
|
@@ -31,13 +31,13 @@ export interface UpdateModeRegistration {
|
|
|
31
31
|
export interface UpdatabilityState {
|
|
32
32
|
active: boolean;
|
|
33
33
|
lastHash: string;
|
|
34
|
-
target:
|
|
34
|
+
target: PiletEntries;
|
|
35
35
|
}
|
|
36
36
|
export interface ListenCallback {
|
|
37
|
-
(notify: (pilets:
|
|
37
|
+
(notify: (pilets: PiletEntries) => void, context: GlobalStateContext): void;
|
|
38
38
|
}
|
|
39
39
|
export interface UpdateDialogProps {
|
|
40
|
-
piletsToUpdate:
|
|
40
|
+
piletsToUpdate: PiletEntries;
|
|
41
41
|
onApprove(): void;
|
|
42
42
|
onReject(): void;
|
|
43
43
|
}
|
package/lib/actions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GlobalStateContext,
|
|
1
|
+
import { GlobalStateContext, PiletEntries } from 'piral-core';
|
|
2
2
|
import { PiletUpdateMode } from './types';
|
|
3
3
|
export declare function rejectUpdate(ctx: GlobalStateContext): void;
|
|
4
4
|
export declare function approveUpdate(ctx: GlobalStateContext): void;
|
|
5
|
-
export declare function checkForUpdates(ctx: GlobalStateContext, pilets:
|
|
5
|
+
export declare function checkForUpdates(ctx: GlobalStateContext, pilets: PiletEntries): void;
|
|
6
6
|
export declare function setUpdateMode(ctx: GlobalStateContext, piletName: string, mode: PiletUpdateMode): void;
|
package/lib/actions.js
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setUpdateMode = exports.checkForUpdates = exports.approveUpdate = exports.rejectUpdate = void 0;
|
|
4
|
-
const piral_base_1 = require("piral-base");
|
|
5
4
|
const piral_core_1 = require("piral-core");
|
|
6
5
|
function getPiletHash(pilet) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
name: pilet.name || '',
|
|
16
|
-
hash: pilet.hash || '',
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
else if ('version' in pilet) {
|
|
20
|
-
return {
|
|
21
|
-
name: pilet.name || '',
|
|
22
|
-
version: pilet.version || '',
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return {
|
|
27
|
-
name: pilet['name'] || '',
|
|
28
|
-
};
|
|
29
|
-
}
|
|
6
|
+
return {
|
|
7
|
+
name: pilet.name,
|
|
8
|
+
version: pilet.version,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function sortPilets(a, b) {
|
|
12
|
+
return a.name.localeCompare(b.name);
|
|
30
13
|
}
|
|
31
14
|
function computePiletHash(pilets) {
|
|
32
|
-
return JSON.stringify(pilets.map(getPiletHash).sort(
|
|
15
|
+
return JSON.stringify(pilets.map(getPiletHash).sort(sortPilets));
|
|
33
16
|
}
|
|
34
17
|
function rejectUpdate(ctx) {
|
|
35
18
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { updatability: Object.assign(Object.assign({}, state.updatability), { target: [], active: false }) })));
|
|
@@ -37,16 +20,8 @@ function rejectUpdate(ctx) {
|
|
|
37
20
|
exports.rejectUpdate = rejectUpdate;
|
|
38
21
|
function approveUpdate(ctx) {
|
|
39
22
|
const pilets = ctx.readState((s) => s.updatability.target);
|
|
40
|
-
for (const
|
|
41
|
-
ctx.
|
|
42
|
-
try {
|
|
43
|
-
ctx.injectPilet(pilet);
|
|
44
|
-
(0, piral_base_1.runPilet)(ctx.options.createApi, pilet, ctx.options.hooks);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.error(error);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
23
|
+
for (const pilet of pilets) {
|
|
24
|
+
ctx.addPilet(pilet);
|
|
50
25
|
}
|
|
51
26
|
ctx.rejectUpdate();
|
|
52
27
|
}
|
package/lib/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;AAAA,2CAAsF;AAGtF,SAAS,YAAY,CAAC,KAAoB;IACxC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,CAAmB,EAAE,CAAmB;IAC1D,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,SAA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
3
|
-
export declare const PiralUpdateDialog:
|
|
3
|
+
export declare const PiralUpdateDialog: ComponentType<UpdateDialogProps>;
|
package/lib/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";;;AACA,2CAA+C;AAGlC,QAAA,iBAAiB,
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";;;AACA,2CAA+C;AAGlC,QAAA,iBAAiB,GAAqC,IAAA,8BAAiB,EAAC,cAAc,CAAC,CAAC"}
|
package/lib/default.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { UpdateDialogProps } from './types';
|
|
3
|
-
export declare const DefaultUpdateDialog:
|
|
3
|
+
export declare const DefaultUpdateDialog: FC<UpdateDialogProps>;
|
package/lib/default.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":";;;AACA,2CAA2C;AAGpC,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":";;;AACA,2CAA2C;AAGpC,MAAM,mBAAmB,GAA0B,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAtF,QAAA,mBAAmB,uBAAmE"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dict, GlobalStateContext,
|
|
1
|
+
import type { Dict, GlobalStateContext, PiletEntries } from 'piral-core';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
declare module 'piral-core/lib/types/custom' {
|
|
4
4
|
interface PiletCustomApi extends PiletUpdateApi {
|
|
@@ -15,7 +15,7 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
15
15
|
interface PiralCustomActions {
|
|
16
16
|
rejectUpdate(): void;
|
|
17
17
|
approveUpdate(): void;
|
|
18
|
-
checkForUpdates(pilets:
|
|
18
|
+
checkForUpdates(pilets: PiletEntries): void;
|
|
19
19
|
setUpdateMode(piletName: string, mode: PiletUpdateMode): void;
|
|
20
20
|
}
|
|
21
21
|
interface PiralCustomComponentsState {
|
|
@@ -31,13 +31,13 @@ export interface UpdateModeRegistration {
|
|
|
31
31
|
export interface UpdatabilityState {
|
|
32
32
|
active: boolean;
|
|
33
33
|
lastHash: string;
|
|
34
|
-
target:
|
|
34
|
+
target: PiletEntries;
|
|
35
35
|
}
|
|
36
36
|
export interface ListenCallback {
|
|
37
|
-
(notify: (pilets:
|
|
37
|
+
(notify: (pilets: PiletEntries) => void, context: GlobalStateContext): void;
|
|
38
38
|
}
|
|
39
39
|
export interface UpdateDialogProps {
|
|
40
|
-
piletsToUpdate:
|
|
40
|
+
piletsToUpdate: PiletEntries;
|
|
41
41
|
onApprove(): void;
|
|
42
42
|
onReject(): void;
|
|
43
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-update",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.3589",
|
|
4
4
|
"description": "Plugin for auto-updating pilets in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"esm",
|
|
27
27
|
"lib",
|
|
28
|
-
"src"
|
|
28
|
+
"src",
|
|
29
|
+
"piral-update.min.js"
|
|
29
30
|
],
|
|
30
31
|
"repository": {
|
|
31
32
|
"type": "git",
|
|
@@ -35,19 +36,21 @@
|
|
|
35
36
|
"url": "https://github.com/smapiot/piral/issues"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {
|
|
38
|
-
"build": "yarn build:commonjs && yarn build:esnext",
|
|
39
|
+
"build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext",
|
|
40
|
+
"build:bundle": "esbuild src/index.ts --outfile=piral-update.min.js --bundle --external:piral-core --external:react --minify --global-name=piralUpdate",
|
|
39
41
|
"build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
|
|
40
42
|
"build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
|
|
41
43
|
"typedoc": "typedoc --json ../../../docs/types/piral-update.json src --exclude \"src/**/*.test.*\"",
|
|
42
44
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"piral-core": "0.15.0-alpha.
|
|
47
|
+
"@types/react": "^17.0.0",
|
|
48
|
+
"piral-core": "0.15.0-alpha.3589",
|
|
49
|
+
"react": "^17.0.1"
|
|
47
50
|
},
|
|
48
51
|
"peerDependencies": {
|
|
49
|
-
"piral-
|
|
50
|
-
"
|
|
52
|
+
"piral-core": "0.14.x",
|
|
53
|
+
"react": ">=16.8.0"
|
|
51
54
|
},
|
|
52
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3de80e7857d8f95c5f7c6944dfad56d4a5e21f8d"
|
|
53
56
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var piralUpdate=(()=>{var M=Object.create;var c=Object.defineProperty,H=Object.defineProperties,w=Object.getOwnPropertyDescriptor,A=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols,j=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var v=(t,e,a)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,n=(t,e)=>{for(var a in e||(e={}))U.call(e,a)&&v(t,a,e[a]);if(k)for(var a of k(e))R.call(e,a)&&v(t,a,e[a]);return t},l=(t,e)=>H(t,A(e)),C=t=>c(t,"__esModule",{value:!0});var d=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,a)=>(typeof require!="undefined"?require:e)[a]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>{C(t);for(var a in e)c(t,a,{get:e[a],enumerable:!0})},T=(t,e,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of G(e))!U.call(t,o)&&o!=="default"&&c(t,o,{get:()=>e[o],enumerable:!(a=w(e,o))||a.enumerable});return t},m=t=>T(C(c(t!=null?M(j(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var X={};S(X,{PiralUpdateDialog:()=>b,UpdateDialog:()=>V,checkPeriodically:()=>h,checkPiralEvent:()=>B,checkServerSentEvents:()=>z,checkWebSocket:()=>q,createUpdateApi:()=>Q});var x=m(d("piral-core")),b=(0,x.getPiralComponent)("UpdateDialog");var g={};S(g,{approveUpdate:()=>J,checkForUpdates:()=>K,rejectUpdate:()=>I,setUpdateMode:()=>_});var D=m(d("piral-core"));function W(t){return{name:t.name,version:t.version}}function N(t,e){return t.name.localeCompare(e.name)}function E(t){return JSON.stringify(t.map(W).sort(N))}function I(t){t.dispatch(e=>l(n({},e),{updatability:l(n({},e.updatability),{target:[],active:!1})}))}function J(t){let e=t.readState(a=>a.updatability.target);for(let a of e)t.addPilet(a);t.rejectUpdate()}function K(t,e){let a=E(e),o=t.readState(r=>r.updatability.lastHash||E(r.modules));if(a!==o){let r=t.readState(p=>p.registry.updatability),i=Object.keys(r),s=i.filter(p=>r[p].mode==="block"),y=i.filter(p=>r[p].mode==="ask"),L=e.filter(p=>!s.includes(p.name)),P=y.length>0;t.dispatch(p=>(P||setTimeout(t.approveUpdate,0),l(n({},p),{updatability:{active:P,lastHash:a,target:L}})))}}function _(t,e,a){t.dispatch(o=>l(n({},o),{registry:l(n({},o.registry),{updatability:(0,D.withKey)(o.registry.updatability,e,{mode:a})})}))}var F=m(d("piral-core")),O=t=>(0,F.defaultRender)(t.children);function h(t={}){let{period:e=5*60*1e3}=t;return(a,o)=>{setInterval(()=>{o.options.fetchPilets().then(a)},e)}}function q(t){let{url:e,available:a}=t;return(o,r)=>{let i=new WebSocket(e);i.onmessage=s=>{a(s.data,s)&&r.options.fetchPilets().then(o)}}}function z(t){let{url:e,name:a,available:o=()=>!0}=t;return(r,i)=>{new EventSource(e).addEventListener(a,y=>{o(y)&&i.options.fetchPilets().then(r)})}}function B(t){let{name:e,available:a=()=>!0}=t;return(o,r)=>{r.on(e,i=>{a(i)&&r.options.fetchPilets().then(o)})}}function Q(t={}){let{listen:e=h()}=t;return a=>(a.defineActions(g),a.dispatch(o=>l(n({},o),{components:n({UpdateDialog:O},o.components),registry:l(n({},o.registry),{updatability:{}}),updatability:{active:!1,lastHash:void 0,target:[]}})),e(a.checkForUpdates,a),(o,r)=>{let i=r.name;return{canUpdate(s){a.setUpdateMode(i,s)}}})}var f=m(d("react")),u=m(d("piral-core"));var V=()=>{let t=(0,u.useActions)(),{active:e,target:a}=(0,u.useGlobalState)(o=>o.updatability);return f.createElement(f.Fragment,null,e&&f.createElement(b,{piletsToUpdate:a,onApprove:t.approveUpdate,onReject:t.rejectUpdate}))};return X;})();
|
package/src/actions.ts
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withKey, GlobalStateContext, PiletMetadata } from 'piral-core';
|
|
1
|
+
import { withKey, GlobalStateContext, PiletEntries, PiletMetadata } from 'piral-core';
|
|
3
2
|
import { PiletUpdateMode } from './types';
|
|
4
3
|
|
|
5
4
|
function getPiletHash(pilet: PiletMetadata) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
hash: pilet.hash || '',
|
|
15
|
-
};
|
|
16
|
-
} else if ('version' in pilet) {
|
|
17
|
-
return {
|
|
18
|
-
name: pilet.name || '',
|
|
19
|
-
version: pilet.version || '',
|
|
20
|
-
};
|
|
21
|
-
} else {
|
|
22
|
-
return {
|
|
23
|
-
name: pilet['name'] || '',
|
|
24
|
-
};
|
|
25
|
-
}
|
|
5
|
+
return {
|
|
6
|
+
name: pilet.name,
|
|
7
|
+
version: pilet.version,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function sortPilets(a: { name: string }, b: { name: string }) {
|
|
12
|
+
return a.name.localeCompare(b.name);
|
|
26
13
|
}
|
|
27
14
|
|
|
28
|
-
function computePiletHash(pilets:
|
|
29
|
-
return JSON.stringify(pilets.map(getPiletHash).sort(
|
|
15
|
+
function computePiletHash(pilets: PiletEntries) {
|
|
16
|
+
return JSON.stringify(pilets.map(getPiletHash).sort(sortPilets));
|
|
30
17
|
}
|
|
31
18
|
|
|
32
19
|
export function rejectUpdate(ctx: GlobalStateContext) {
|
|
@@ -43,21 +30,14 @@ export function rejectUpdate(ctx: GlobalStateContext) {
|
|
|
43
30
|
export function approveUpdate(ctx: GlobalStateContext) {
|
|
44
31
|
const pilets = ctx.readState((s) => s.updatability.target);
|
|
45
32
|
|
|
46
|
-
for (const
|
|
47
|
-
ctx.
|
|
48
|
-
try {
|
|
49
|
-
ctx.injectPilet(pilet);
|
|
50
|
-
runPilet(ctx.options.createApi, pilet, ctx.options.hooks);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error(error);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
33
|
+
for (const pilet of pilets) {
|
|
34
|
+
ctx.addPilet(pilet);
|
|
55
35
|
}
|
|
56
36
|
|
|
57
37
|
ctx.rejectUpdate();
|
|
58
38
|
}
|
|
59
39
|
|
|
60
|
-
export function checkForUpdates(ctx: GlobalStateContext, pilets:
|
|
40
|
+
export function checkForUpdates(ctx: GlobalStateContext, pilets: PiletEntries) {
|
|
61
41
|
const checkHash = computePiletHash(pilets);
|
|
62
42
|
const lastHash = ctx.readState((s) => s.updatability.lastHash || computePiletHash(s.modules));
|
|
63
43
|
|
package/src/components.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
2
|
import { getPiralComponent } from 'piral-core';
|
|
3
3
|
import { UpdateDialogProps } from './types';
|
|
4
4
|
|
|
5
|
-
export const PiralUpdateDialog:
|
|
5
|
+
export const PiralUpdateDialog: ComponentType<UpdateDialogProps> = getPiralComponent('UpdateDialog');
|
package/src/default.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { defaultRender } from 'piral-core';
|
|
3
3
|
import { UpdateDialogProps } from './types';
|
|
4
4
|
|
|
5
|
-
export const DefaultUpdateDialog:
|
|
5
|
+
export const DefaultUpdateDialog: FC<UpdateDialogProps> = (props) => defaultRender(props.children);
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dict, GlobalStateContext,
|
|
1
|
+
import type { Dict, GlobalStateContext, PiletEntries } from 'piral-core';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
declare module 'piral-core/lib/types/custom' {
|
|
@@ -20,7 +20,7 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
20
20
|
|
|
21
21
|
approveUpdate(): void;
|
|
22
22
|
|
|
23
|
-
checkForUpdates(pilets:
|
|
23
|
+
checkForUpdates(pilets: PiletEntries): void;
|
|
24
24
|
|
|
25
25
|
setUpdateMode(piletName: string, mode: PiletUpdateMode): void;
|
|
26
26
|
}
|
|
@@ -40,15 +40,15 @@ export interface UpdateModeRegistration {
|
|
|
40
40
|
export interface UpdatabilityState {
|
|
41
41
|
active: boolean;
|
|
42
42
|
lastHash: string;
|
|
43
|
-
target:
|
|
43
|
+
target: PiletEntries;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface ListenCallback {
|
|
47
|
-
(notify: (pilets:
|
|
47
|
+
(notify: (pilets: PiletEntries) => void, context: GlobalStateContext): void;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export interface UpdateDialogProps {
|
|
51
|
-
piletsToUpdate:
|
|
51
|
+
piletsToUpdate: PiletEntries;
|
|
52
52
|
onApprove(): void;
|
|
53
53
|
onReject(): void;
|
|
54
54
|
}
|