@codenotch/codenotch.react 1.0.81 → 1.0.82
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/README.md +8 -8
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/models/Codenotch.d.ts +10 -11
- package/dist/models/Codenotch.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +4 -5
- package/src/models/Codenotch.ts +10 -11
- package/src/models/AppManifestModels.ts +0 -54
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
React bindings for [Codenotch](https://codenotch.com) applications.
|
|
4
4
|
|
|
5
|
-
Codenotch is a full-stack development platform: a project combines server-side **BPMN processes**, **SQL tables** / **NoSQL documents**, **i18n** translations and **React** apps. This package is the client-side bridge between those React apps and the Codenotch runtime: it lets a component start BPMN processes, run
|
|
5
|
+
Codenotch is a full-stack development platform: a project combines server-side **BPMN processes**, **SQL tables** / **NoSQL documents**, **i18n** translations and **React** apps. This package is the client-side bridge between those React apps and the Codenotch runtime: it lets a component start BPMN processes, run CNQL queries, translate i18n keys, listen to real-time signals, and manage theme/language.
|
|
6
6
|
|
|
7
7
|
> **Requirements** — Codenotch apps run on **React 16** (`react@^16.14.0`). Do not use React 17/18 APIs (`createRoot`, `useId`, automatic JSX runtime…); hooks work fine.
|
|
8
8
|
|
|
@@ -34,7 +34,7 @@ The environment (cluster URL, service name, language, translations…) is set up
|
|
|
34
34
|
| `cn.env` | Readonly environment: `clusterUrl`, `serviceName`, `tenantName`, `accessToken`, `language`, `theme`, `i18n`, `appManifest`, `projectManifest`. |
|
|
35
35
|
| `cn.i18n(key, ...args)` | Translate a key for the current language, filling `{0}`, `{1}`, … placeholders. |
|
|
36
36
|
| `cn.startProcess(name, startNodeId, inputs)` | Start a server-side BPMN process and await its result. |
|
|
37
|
-
| `cn.
|
|
37
|
+
| `cn.requestCnql(cnql, verbose?)` | Run a CNQL query (XML, SELECT-only) against the project's tables. |
|
|
38
38
|
| `cn.listenSignal(signalId, callback)` | Subscribe to real-time signals emitted by BPMN processes. |
|
|
39
39
|
| `cn.showDialog(jsx)` | Render a JSX element in a fullscreen modal dialog. |
|
|
40
40
|
| `cn.setTheme(t)` / `cn.getTheme()` | `'light' \| 'dark'`; `setTheme` also toggles the class on `<html>` (Tailwind `dark:`). |
|
|
@@ -60,19 +60,19 @@ if (!result.isError) {
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
## Querying tables with
|
|
63
|
+
## Querying tables with CNQL
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
CNQL is Codenotch's XML query language over the project's SQL tables (SELECT only — writes go through BPMN processes). The root `xmlns` must be the project's `serviceName`; each queried table's `Ref` attribute names its result set:
|
|
66
66
|
|
|
67
67
|
```tsx
|
|
68
|
-
const data = await cn.
|
|
69
|
-
<
|
|
68
|
+
const data = await cn.requestCnql(`
|
|
69
|
+
<CNQL xmlns="myproject" PageSize="10" PageIndex="0">
|
|
70
70
|
<Users Ref="results">
|
|
71
71
|
<Id />
|
|
72
72
|
<Email />
|
|
73
73
|
<IsAdmin Equal="true" />
|
|
74
74
|
</Users>
|
|
75
|
-
</
|
|
75
|
+
</CNQL>`);
|
|
76
76
|
|
|
77
77
|
console.log(data.results); // [{ Id: '...', Email: '...' }, ...]
|
|
78
78
|
```
|
|
@@ -142,4 +142,4 @@ With these in the compilation, keys, inputs and outputs are strictly checked and
|
|
|
142
142
|
- The complete typed API surface is in `dist/index.d.ts`; the readable implementation ships in `src/` (entry point `src/index.ts`).
|
|
143
143
|
- `useCodenotch()` is a plain function, not a hook — no hook rules apply.
|
|
144
144
|
- Never hand-edit a project's `typings/i18n.d.ts` / `typings/process.d.ts`: they are regenerated by the Codenotch IDE.
|
|
145
|
-
- Codenotch apps are React 16 + Tailwind CSS;
|
|
145
|
+
- Codenotch apps are React 16 + Tailwind CSS; CNQL is SELECT-only (writes go through BPMN processes via `startProcess`).
|
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ declare function init(envVariables: any): void;
|
|
|
42
42
|
* modules). `init()` must have been called first, which the Codenotch runtime
|
|
43
43
|
* does automatically when serving the application.
|
|
44
44
|
*
|
|
45
|
-
* @returns The Codenotch API: BPMN processes,
|
|
45
|
+
* @returns The Codenotch API: BPMN processes, CNQL queries, i18n, signals, theme…
|
|
46
46
|
* @example
|
|
47
47
|
* import { useCodenotch } from 'codenotch-react';
|
|
48
48
|
*
|
|
@@ -55,6 +55,5 @@ declare function useCodenotch(): ICodenotchApi;
|
|
|
55
55
|
export { env, useCodenotch, init, CodeEditor };
|
|
56
56
|
export * from "./models/Codenotch";
|
|
57
57
|
export * from "./models/Misc";
|
|
58
|
-
export * from "./models/AppManifestModels";
|
|
59
58
|
export * from "@codenotch/codenotch.core";
|
|
60
59
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAoB,aAAa,EAAkB,MAAM,oBAAoB,CAAC;AAEpG,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAIjD;;;GAGG;AACH,QAAA,MAAM,GAAG,EAAE,aAAkB,CAAC;AAM9B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,iBAAS,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,CAyFrC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,YAAY,IAAI,aAAa,CAsNrC;AAED,OAAO,EACH,GAAG,EACH,YAAY,EACZ,IAAI,EACJ,UAAU,EACb,CAAC;AAMF,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAoB,aAAa,EAAkB,MAAM,oBAAoB,CAAC;AAEpG,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAIjD;;;GAGG;AACH,QAAA,MAAM,GAAG,EAAE,aAAkB,CAAC;AAM9B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,iBAAS,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,CAyFrC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,YAAY,IAAI,aAAa,CAsNrC;AAED,OAAO,EACH,GAAG,EACH,YAAY,EACZ,IAAI,EACJ,UAAU,EACb,CAAC;AAMF,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -150,7 +150,7 @@ function init(envVariables) {
|
|
|
150
150
|
* modules). `init()` must have been called first, which the Codenotch runtime
|
|
151
151
|
* does automatically when serving the application.
|
|
152
152
|
*
|
|
153
|
-
* @returns The Codenotch API: BPMN processes,
|
|
153
|
+
* @returns The Codenotch API: BPMN processes, CNQL queries, i18n, signals, theme…
|
|
154
154
|
* @example
|
|
155
155
|
* import { useCodenotch } from 'codenotch-react';
|
|
156
156
|
*
|
|
@@ -183,7 +183,7 @@ function useCodenotch() {
|
|
|
183
183
|
let content = await resp.text();
|
|
184
184
|
return content;
|
|
185
185
|
},
|
|
186
|
-
|
|
186
|
+
requestCnql: async (cnql, verbose) => {
|
|
187
187
|
if (env.clusterUrl === undefined)
|
|
188
188
|
throw new Error(MISSING_CLUSTER_URL_ERROR);
|
|
189
189
|
if (env.serviceName === undefined)
|
|
@@ -193,7 +193,7 @@ function useCodenotch() {
|
|
|
193
193
|
mode: 'cors',
|
|
194
194
|
credentials: 'same-origin',
|
|
195
195
|
headers: { 'Content-Type': 'application/json' },
|
|
196
|
-
body: `"${
|
|
196
|
+
body: `"${cnql.replace(/\"/g, '\\\"')}"`
|
|
197
197
|
};
|
|
198
198
|
if (`${env.accessToken ?? ''}`.trim() !== "") {
|
|
199
199
|
if (env.tenantName === undefined)
|
|
@@ -202,7 +202,7 @@ function useCodenotch() {
|
|
|
202
202
|
...request.headers, [`${env.tenantName}AccessToken`]: env.accessToken
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
const response = await fetch(`${env.clusterUrl}/${env.serviceName}/
|
|
205
|
+
const response = await fetch(`${env.clusterUrl}/${env.serviceName}/cnql${verbose ? "?v=true" : ""}`, request);
|
|
206
206
|
if (!response.ok) {
|
|
207
207
|
const error = await response.text();
|
|
208
208
|
throw new Error(error);
|
|
@@ -366,5 +366,4 @@ function useCodenotch() {
|
|
|
366
366
|
// TranslationRegistry / ProcessRegistry declarations.
|
|
367
367
|
__exportStar(require("./models/Codenotch"), exports);
|
|
368
368
|
__exportStar(require("./models/Misc"), exports);
|
|
369
|
-
__exportStar(require("./models/AppManifestModels"), exports);
|
|
370
369
|
__exportStar(require("@codenotch/codenotch.core"), exports);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ProjectManifest } from "@codenotch/codenotch.core";
|
|
1
|
+
import { ProjectManifest, IAppManifest } from "@codenotch/codenotch.core";
|
|
2
2
|
import { ICodenotchSignal, IDisposable } from "./Misc";
|
|
3
|
-
import { ApplicationManifest } from "./AppManifestModels";
|
|
4
3
|
/**
|
|
5
4
|
* Runtime environment of a Codenotch application.
|
|
6
5
|
*
|
|
@@ -31,7 +30,7 @@ export interface ICodenotchEnv {
|
|
|
31
30
|
/** Current UI theme. Resolved from the `_theme` URL parameter, or `prefers-color-scheme` as a fallback. */
|
|
32
31
|
theme?: 'light' | 'dark';
|
|
33
32
|
/** Manifest of the current application (the `<AppName>.manifest.json` file next to the app). */
|
|
34
|
-
appManifest?:
|
|
33
|
+
appManifest?: IAppManifest;
|
|
35
34
|
/** Manifest of the Codenotch project (the project's `manifest.json` file). */
|
|
36
35
|
projectManifest?: ProjectManifest;
|
|
37
36
|
/** Any additional environment variable passed to `init()`. */
|
|
@@ -123,7 +122,7 @@ export interface IProcessResult<T = any> {
|
|
|
123
122
|
* The Codenotch client API, obtained by calling `useCodenotch()`.
|
|
124
123
|
*
|
|
125
124
|
* It is the bridge between a React app and the Codenotch runtime: it starts
|
|
126
|
-
* server-side BPMN processes, runs
|
|
125
|
+
* server-side BPMN processes, runs CNQL queries, translates i18n keys,
|
|
127
126
|
* listens to real-time signals and manages theme/language.
|
|
128
127
|
*
|
|
129
128
|
* @example
|
|
@@ -165,24 +164,24 @@ export interface ICodenotchApi {
|
|
|
165
164
|
/** Runtime environment (cluster, service, language, theme, i18n dictionaries, manifests…). Populated by `init()`. */
|
|
166
165
|
readonly env: ICodenotchEnv;
|
|
167
166
|
/**
|
|
168
|
-
* Execute a
|
|
167
|
+
* Execute a CNQL query (XML, SELECT-only) against the project's SQL tables and return the parsed JSON result.
|
|
169
168
|
*
|
|
170
169
|
* The root element's `xmlns` must be the project's `serviceName`. Results are
|
|
171
170
|
* keyed by the `Ref` attribute of each queried table.
|
|
172
171
|
*
|
|
173
|
-
* @param
|
|
172
|
+
* @param cnql The CNQL XML query.
|
|
174
173
|
* @param verbose When `true`, asks the server for a verbose response (debugging).
|
|
175
174
|
* @example
|
|
176
|
-
* const data = await cn.
|
|
177
|
-
* <
|
|
175
|
+
* const data = await cn.requestCnql(`
|
|
176
|
+
* <CNQL xmlns="myproject" PageSize="10" PageIndex="0">
|
|
178
177
|
* <Users Ref="results">
|
|
179
178
|
* <Id />
|
|
180
179
|
* <Email />
|
|
181
180
|
* </Users>
|
|
182
|
-
* </
|
|
181
|
+
* </CNQL>`);
|
|
183
182
|
* console.log(data.results); // [{ Id: ..., Email: ... }, ...]
|
|
184
183
|
*/
|
|
185
|
-
readonly
|
|
184
|
+
readonly requestCnql: (cnql: string, verbose?: boolean) => Promise<any>;
|
|
186
185
|
/**
|
|
187
186
|
* Render the given React element in a fullscreen modal `<dialog>` overlay.
|
|
188
187
|
*
|
|
@@ -242,7 +241,7 @@ export interface ICodenotchApi {
|
|
|
242
241
|
/** Manifest of the Codenotch project. Throws if not available in the environment. */
|
|
243
242
|
readonly getProjectManifest: () => ProjectManifest;
|
|
244
243
|
/** Manifest of the current application, if any. */
|
|
245
|
-
readonly getAppManifest: () =>
|
|
244
|
+
readonly getAppManifest: () => IAppManifest | undefined;
|
|
246
245
|
}
|
|
247
246
|
/**
|
|
248
247
|
* Handle on a dialog opened with {@link ICodenotchApi.showDialog}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Codenotch.d.ts","sourceRoot":"","sources":["../../src/models/Codenotch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"Codenotch.d.ts","sourceRoot":"","sources":["../../src/models/Codenotch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oHAAoH;IACpH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yGAAyG;IACzG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yGAAyG;IACzG,IAAI,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACzD,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2GAA2G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|
2
2
|
"name": "@codenotch/codenotch.react",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "React bindings for Codenotch applications: start BPMN processes, run
|
|
3
|
+
"version": "1.0.82",
|
|
4
|
+
"description": "React bindings for Codenotch applications: start BPMN processes, run cnql queries, translate i18n keys, listen to real-time signals, manage theme and language.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codenotch",
|
|
7
7
|
"react"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"src/**/*"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@codenotch/codenotch.core": "1.0.
|
|
28
|
+
"@codenotch/codenotch.core": "1.0.21",
|
|
29
29
|
"@microsoft/signalr": "^5.0.6",
|
|
30
30
|
"uuid": "^8.2.0"
|
|
31
31
|
},
|
package/src/index.ts
CHANGED
|
@@ -145,7 +145,7 @@ function init(envVariables: any): void {
|
|
|
145
145
|
* modules). `init()` must have been called first, which the Codenotch runtime
|
|
146
146
|
* does automatically when serving the application.
|
|
147
147
|
*
|
|
148
|
-
* @returns The Codenotch API: BPMN processes,
|
|
148
|
+
* @returns The Codenotch API: BPMN processes, CNQL queries, i18n, signals, theme…
|
|
149
149
|
* @example
|
|
150
150
|
* import { useCodenotch } from 'codenotch-react';
|
|
151
151
|
*
|
|
@@ -175,7 +175,7 @@ function useCodenotch(): ICodenotchApi {
|
|
|
175
175
|
let content = await resp.text();
|
|
176
176
|
return content;
|
|
177
177
|
},
|
|
178
|
-
|
|
178
|
+
requestCnql: async (cnql: string, verbose?: boolean): Promise<any> => {
|
|
179
179
|
if (env.clusterUrl === undefined) throw new Error(MISSING_CLUSTER_URL_ERROR);
|
|
180
180
|
if (env.serviceName === undefined) throw new Error(MISSING_SERVICE_NAME_ERROR);
|
|
181
181
|
|
|
@@ -184,7 +184,7 @@ function useCodenotch(): ICodenotchApi {
|
|
|
184
184
|
mode: 'cors',
|
|
185
185
|
credentials: 'same-origin',
|
|
186
186
|
headers: { 'Content-Type': 'application/json' },
|
|
187
|
-
body: `"${
|
|
187
|
+
body: `"${cnql.replace(/\"/g, '\\\"')}"`
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
if (`${env.accessToken ?? ''}`.trim() !== "") {
|
|
@@ -194,7 +194,7 @@ function useCodenotch(): ICodenotchApi {
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
const response = await fetch(`${env.clusterUrl}/${env.serviceName}/
|
|
197
|
+
const response = await fetch(`${env.clusterUrl}/${env.serviceName}/cnql${verbose ? "?v=true" : ""}`, request);
|
|
198
198
|
if (!response.ok) {
|
|
199
199
|
const error = await response.text();
|
|
200
200
|
throw new Error(error);
|
|
@@ -383,5 +383,4 @@ export {
|
|
|
383
383
|
// TranslationRegistry / ProcessRegistry declarations.
|
|
384
384
|
export * from "./models/Codenotch";
|
|
385
385
|
export * from "./models/Misc";
|
|
386
|
-
export * from "./models/AppManifestModels";
|
|
387
386
|
export * from "@codenotch/codenotch.core";
|
package/src/models/Codenotch.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ProjectManifest } from "@codenotch/codenotch.core";
|
|
1
|
+
import { ProjectManifest, IAppManifest } from "@codenotch/codenotch.core";
|
|
2
2
|
import { ICodenotchSignal, IDisposable } from "./Misc";
|
|
3
|
-
import { ApplicationManifest } from "./AppManifestModels";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Runtime environment of a Codenotch application.
|
|
@@ -29,7 +28,7 @@ export interface ICodenotchEnv {
|
|
|
29
28
|
theme?: 'light' | 'dark';
|
|
30
29
|
|
|
31
30
|
/** Manifest of the current application (the `<AppName>.manifest.json` file next to the app). */
|
|
32
|
-
appManifest?:
|
|
31
|
+
appManifest?: IAppManifest;
|
|
33
32
|
/** Manifest of the Codenotch project (the project's `manifest.json` file). */
|
|
34
33
|
projectManifest?: ProjectManifest;
|
|
35
34
|
|
|
@@ -138,7 +137,7 @@ export interface IProcessResult<T = any> {
|
|
|
138
137
|
* The Codenotch client API, obtained by calling `useCodenotch()`.
|
|
139
138
|
*
|
|
140
139
|
* It is the bridge between a React app and the Codenotch runtime: it starts
|
|
141
|
-
* server-side BPMN processes, runs
|
|
140
|
+
* server-side BPMN processes, runs CNQL queries, translates i18n keys,
|
|
142
141
|
* listens to real-time signals and manages theme/language.
|
|
143
142
|
*
|
|
144
143
|
* @example
|
|
@@ -191,24 +190,24 @@ export interface ICodenotchApi {
|
|
|
191
190
|
readonly env: ICodenotchEnv;
|
|
192
191
|
|
|
193
192
|
/**
|
|
194
|
-
* Execute a
|
|
193
|
+
* Execute a CNQL query (XML, SELECT-only) against the project's SQL tables and return the parsed JSON result.
|
|
195
194
|
*
|
|
196
195
|
* The root element's `xmlns` must be the project's `serviceName`. Results are
|
|
197
196
|
* keyed by the `Ref` attribute of each queried table.
|
|
198
197
|
*
|
|
199
|
-
* @param
|
|
198
|
+
* @param cnql The CNQL XML query.
|
|
200
199
|
* @param verbose When `true`, asks the server for a verbose response (debugging).
|
|
201
200
|
* @example
|
|
202
|
-
* const data = await cn.
|
|
203
|
-
* <
|
|
201
|
+
* const data = await cn.requestCnql(`
|
|
202
|
+
* <CNQL xmlns="myproject" PageSize="10" PageIndex="0">
|
|
204
203
|
* <Users Ref="results">
|
|
205
204
|
* <Id />
|
|
206
205
|
* <Email />
|
|
207
206
|
* </Users>
|
|
208
|
-
* </
|
|
207
|
+
* </CNQL>`);
|
|
209
208
|
* console.log(data.results); // [{ Id: ..., Email: ... }, ...]
|
|
210
209
|
*/
|
|
211
|
-
readonly
|
|
210
|
+
readonly requestCnql: (cnql: string, verbose?: boolean) => Promise<any>;
|
|
212
211
|
|
|
213
212
|
/**
|
|
214
213
|
* Render the given React element in a fullscreen modal `<dialog>` overlay.
|
|
@@ -271,7 +270,7 @@ export interface ICodenotchApi {
|
|
|
271
270
|
/** Manifest of the Codenotch project. Throws if not available in the environment. */
|
|
272
271
|
readonly getProjectManifest: () => ProjectManifest;
|
|
273
272
|
/** Manifest of the current application, if any. */
|
|
274
|
-
readonly getAppManifest: () =>
|
|
273
|
+
readonly getAppManifest: () => IAppManifest | undefined;
|
|
275
274
|
}
|
|
276
275
|
|
|
277
276
|
/**
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export interface ApplicationManifest {
|
|
3
|
-
pwa?: PWAManifest;
|
|
4
|
-
|
|
5
|
-
html?: HTMLManifest;
|
|
6
|
-
|
|
7
|
-
auml?: AUMLManifest;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface HTMLManifest {
|
|
11
|
-
title?: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
author?: string;
|
|
14
|
-
keywords?: string;
|
|
15
|
-
charset?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface PWAManifest {
|
|
19
|
-
background_color?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
dir?: string;
|
|
22
|
-
display?: string;
|
|
23
|
-
icons?: PWAManifestIcon[];
|
|
24
|
-
lang?: string;
|
|
25
|
-
name?: string;
|
|
26
|
-
orientation?: string;
|
|
27
|
-
prefer_related_applications?: boolean;
|
|
28
|
-
related_applications?: PWAManifestRelatedApplications[];
|
|
29
|
-
scope?: string;
|
|
30
|
-
short_name?: string;
|
|
31
|
-
start_url?: string;
|
|
32
|
-
theme_color?: string;
|
|
33
|
-
shortcuts?: string;
|
|
34
|
-
|
|
35
|
-
display_override?: string[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface PWAManifestIcon {
|
|
39
|
-
src?: string;
|
|
40
|
-
sizes?: string;
|
|
41
|
-
type?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface PWAManifestRelatedApplications {
|
|
45
|
-
platform?: string;
|
|
46
|
-
url?: string;
|
|
47
|
-
id?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface AUMLManifest {
|
|
51
|
-
name?: string;
|
|
52
|
-
description?: string;
|
|
53
|
-
logoURL?: string;
|
|
54
|
-
}
|