@codenotch/codenotch.react 2.0.0 → 2.0.1

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/index.d.ts CHANGED
@@ -15,7 +15,6 @@ declare const env: ICodenotchEnv;
15
15
  * any other source). It must be called before `useCodenotch()` is used.
16
16
  *
17
17
  * Recognized key formats:
18
- * - `i18n.<key>.<language>` — a translation, stored in `env.i18n[language][key]`.
19
18
  * The first language found becomes the current language if none is set.
20
19
  * - `GLOBAL.<name>` — JSON value assigned to `window[name]` (or `globalThis`).
21
20
  * - `appManifest` / `projectManifest` — parsed as JSON into the environment.
@@ -30,9 +29,7 @@ declare const env: ICodenotchEnv;
30
29
  * init({
31
30
  * clusterUrl: 'https://cluster.example.com',
32
31
  * serviceName: 'myproject',
33
- * tenantName: 'acme',
34
- * 'i18n.welcome.en': 'Welcome',
35
- * 'i18n.welcome.fr': 'Bienvenue'
32
+ * tenantName: 'acme'
36
33
  * });
37
34
  */
38
35
  declare function init(envVariables: any): void;
@@ -63,7 +60,7 @@ declare function getCodenotch(): ICodenotchApi;
63
60
  *
64
61
  * The reference is stable across renders and only changes when the environment
65
62
  * changes (`setLanguage`, `setTheme`, `init`), in which case every component
66
- * using the hook re-renders — so `cn.i18n(...)` output follows the current
63
+ * using the hook re-renders output follows the current
67
64
  * language automatically, and the object is safe to use in `useMemo` /
68
65
  * `useEffect` dependency arrays.
69
66
  *
@@ -71,15 +68,6 @@ declare function getCodenotch(): ICodenotchApi;
71
68
  * component or a custom hook). Outside of components — handlers defined in
72
69
  * plain modules, services, class components — use {@link getCodenotch} or
73
70
  * {@link withCodenotch} instead.
74
- *
75
- * @returns The Codenotch API: BPMN processes, CNQL queries, i18n, signals, theme…
76
- * @example
77
- * import { useCodenotch } from 'codenotch-react';
78
- *
79
- * const MyApp = () => {
80
- * const cn = useCodenotch();
81
- * return <h1>{cn.i18n('welcome')}</h1>;
82
- * };
83
71
  */
84
72
  declare function useCodenotch(): ICodenotchApi;
85
73
  /**
@@ -112,21 +100,6 @@ type ComponentInstance<C> = C extends new (...args: any[]) => infer I ? I : neve
112
100
  *
113
101
  * @param Component A component whose props extend {@link WithCodenotchProps}.
114
102
  * @returns A component with the same props minus `cn`.
115
- * @example
116
- * import { withCodenotch, WithCodenotchProps } from 'codenotch-react';
117
- *
118
- * interface Props extends WithCodenotchProps {
119
- * userId: string;
120
- * }
121
- *
122
- * class TodoList extends React.Component<Props> {
123
- * render() {
124
- * return <h1>{this.props.cn.i18n('todos.title')}</h1>;
125
- * }
126
- * }
127
- *
128
- * export default withCodenotch(TodoList);
129
- * // <TodoList userId="42" /> — `cn` is injected
130
103
  */
131
104
  declare function withCodenotch<C extends ComponentType<any>>(Component: C): FunctionComponent<WithoutCodenotchProps<ComponentProps<C>> & RefAttributes<ComponentInstance<C>>>;
132
105
  export { env, useCodenotch, getCodenotch, withCodenotch, onCodenotchChange, init, CodeEditor };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAkB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAKjK,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAoB,aAAa,EAAkB,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExH,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAIjD;;;GAGG;AACH,QAAA,MAAM,GAAG,EAAE,aAAkB,CAAC;AA6B9B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,iBAAS,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,CA2FrC;AA2OD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,YAAY,IAAI,aAAa,CAErC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAA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;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAS,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,CA0DrC;AA2KD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,YAAY,IAAI,aAAa,CAErC;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,YAAY,IAAI,aAAa,CAErC;AAED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,iBAAiB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAG5D;AAED,wFAAwF;AACxF,KAAK,qBAAqB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,kBAAkB,CAAC,CAAC;AAElE,8FAA8F;AAC9F,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAElF;;;;;;;;;;GAUG;AACH,iBAAS,aAAa,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAC/C,SAAS,EAAE,CAAC,GACb,iBAAiB,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAQnG;AAED,OAAO,EACH,GAAG,EACH,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,UAAU,EACb,CAAC;AAEF,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -26,12 +26,9 @@ exports.init = init;
26
26
  const react_1 = require("react");
27
27
  const react_dom_1 = require("react-dom");
28
28
  const client_1 = require("react-dom/client");
29
- const SignalR_1 = require("./core/SignalR");
30
- const ProcessUtils_1 = __importDefault(require("./core/ProcessUtils"));
31
29
  const uuid_1 = require("uuid");
32
30
  const CodeEditor_1 = __importDefault(require("./components/CodeEditor"));
33
31
  exports.CodeEditor = CodeEditor_1.default;
34
- var signalR = undefined;
35
32
  /**
36
33
  * The Codenotch runtime environment, populated by {@link init}.
37
34
  * Prefer reading it through `useCodenotch().env`.
@@ -73,7 +70,6 @@ function subscribe(listener) {
73
70
  * any other source). It must be called before `useCodenotch()` is used.
74
71
  *
75
72
  * Recognized key formats:
76
- * - `i18n.<key>.<language>` — a translation, stored in `env.i18n[language][key]`.
77
73
  * The first language found becomes the current language if none is set.
78
74
  * - `GLOBAL.<name>` — JSON value assigned to `window[name]` (or `globalThis`).
79
75
  * - `appManifest` / `projectManifest` — parsed as JSON into the environment.
@@ -88,15 +84,12 @@ function subscribe(listener) {
88
84
  * init({
89
85
  * clusterUrl: 'https://cluster.example.com',
90
86
  * serviceName: 'myproject',
91
- * tenantName: 'acme',
92
- * 'i18n.welcome.en': 'Welcome',
93
- * 'i18n.welcome.fr': 'Bienvenue'
87
+ * tenantName: 'acme'
94
88
  * });
95
89
  */
96
90
  function init(envVariables) {
97
91
  // Ensure envVariables is an object
98
92
  if (typeof envVariables === 'object' && envVariables !== null) {
99
- let i18nLanguages = new Set();
100
93
  Object.keys(envVariables).forEach((key) => {
101
94
  try {
102
95
  if (key.startsWith('GLOBAL.')) {
@@ -107,21 +100,6 @@ function init(envVariables) {
107
100
  console.log(`Codenotch global variable ${globalKey} set!`);
108
101
  return;
109
102
  }
110
- else if (key.startsWith("i18n.")) {
111
- // Special case
112
- let parts = key.split("."); // i18n.someKey.fr
113
- let language = parts[parts.length - 1]; // fr
114
- let keyName = parts.slice(1, parts.length - 1).join("."); // someKey
115
- i18nLanguages.add(language);
116
- let value = `${envVariables[key]}`.trim();
117
- if (value.startsWith('"') && value.endsWith('"')) {
118
- // Parse like json
119
- value = JSON.parse(value);
120
- }
121
- env.i18n = env.i18n ?? {};
122
- env.i18n[language] = env.i18n[language] ?? {};
123
- env.i18n[language][keyName] = value;
124
- }
125
103
  else {
126
104
  env[key] = envVariables[key];
127
105
  if (['appManifest', 'projectManifest'].includes(key)) {
@@ -140,17 +118,6 @@ function init(envVariables) {
140
118
  console.error(`Error processing Codenotch environment variable ${key}:`, error);
141
119
  }
142
120
  });
143
- if (env.language === undefined) {
144
- // If current language is not defined, we set it to the first language found in i18n
145
- if (i18nLanguages.size > 0) {
146
- env.language = Array.from(i18nLanguages)[0];
147
- console.log(`Codenotch current language set to ${env.language}`);
148
- }
149
- }
150
- }
151
- // Instantiate SignalR for further use in the API
152
- if (env.clusterUrl && env.serviceName) {
153
- signalR = new SignalR_1.SignalR(env.clusterUrl, env.serviceName, false, env.accessToken);
154
121
  }
155
122
  // Get theme like AEC does
156
123
  try {
@@ -227,48 +194,8 @@ function createApi() {
227
194
  }
228
195
  return await response.json();
229
196
  },
230
- i18n: (key, ...args) => {
231
- try {
232
- if (env.i18n === undefined || Object.keys(env.i18n).length === 0) {
233
- console.warn("Codenotch i18n is not defined. Please set it in the Codenotch configuration.");
234
- return key;
235
- }
236
- let language = env.language ?? "en";
237
- let isLanguageExists = env.i18n[language] !== undefined;
238
- if (isLanguageExists === false) {
239
- let fallbackLanguage = Object.keys(env.i18n)[0];
240
- console.warn(`Codenotch i18n language ${language} is not defined. Falling back to ${fallbackLanguage}. Please set the correct language in the Codenotch configuration.`);
241
- language = fallbackLanguage;
242
- }
243
- let dico = env.i18n[language];
244
- let value = dico[key];
245
- if (typeof value !== "string") {
246
- console.warn(`Codenotch i18n key ${key} is not defined for language ${language}. Please set it in the Codenotch configuration.`);
247
- return key;
248
- }
249
- args = args ?? [];
250
- let result = value.replace(/{([\d ]*)}/g, (match, p1) => {
251
- let argValue = args[p1.trim()];
252
- // Instead of returning 'undefined', returns an empty string
253
- return argValue !== undefined ? argValue : "";
254
- });
255
- return result;
256
- }
257
- catch (error) {
258
- console.error("Error in i18n function:", error);
259
- return key;
260
- }
261
- },
262
- startProcess: async (processName, startNodeId, inputs) => {
263
- if (env.clusterUrl === undefined)
264
- throw new Error(MISSING_CLUSTER_URL_ERROR);
265
- if (env.serviceName === undefined)
266
- throw new Error(MISSING_SERVICE_NAME_ERROR);
267
- if (env.tenantName === undefined)
268
- throw new Error(MISSING_TENANT_NAME_ERROR);
269
- if (signalR === undefined)
270
- throw new Error("SignalR not available. Cannot start process.");
271
- return ProcessUtils_1.default.startProcess((processInstanceId, callbacks) => signalR.subscribeToProcessInstance(processInstanceId, callbacks), env.clusterUrl, env.tenantName, env.serviceName, processName, inputs, undefined, startNodeId ?? 'start', env.accessToken);
197
+ startProcess: async (process, inputs) => {
198
+ throw new Error('Not implemented.');
272
199
  },
273
200
  getUrlParams: () => {
274
201
  let result = {};
@@ -341,17 +268,6 @@ function createApi() {
341
268
  dialogElement.showModal();
342
269
  return result;
343
270
  },
344
- listenSignal: async (signalId, callback) => {
345
- if (!signalR) {
346
- throw new Error("SignalR not available. Cannot listen to signal.");
347
- }
348
- let unsubscribeFunc = await signalR.subscribeToSignal(signalId, callback);
349
- return {
350
- dispose: () => {
351
- unsubscribeFunc();
352
- }
353
- };
354
- },
355
271
  setTheme: (theme) => {
356
272
  if (env.theme === theme)
357
273
  return;
@@ -418,7 +334,7 @@ function getCodenotch() {
418
334
  *
419
335
  * The reference is stable across renders and only changes when the environment
420
336
  * changes (`setLanguage`, `setTheme`, `init`), in which case every component
421
- * using the hook re-renders — so `cn.i18n(...)` output follows the current
337
+ * using the hook re-renders output follows the current
422
338
  * language automatically, and the object is safe to use in `useMemo` /
423
339
  * `useEffect` dependency arrays.
424
340
  *
@@ -426,15 +342,6 @@ function getCodenotch() {
426
342
  * component or a custom hook). Outside of components — handlers defined in
427
343
  * plain modules, services, class components — use {@link getCodenotch} or
428
344
  * {@link withCodenotch} instead.
429
- *
430
- * @returns The Codenotch API: BPMN processes, CNQL queries, i18n, signals, theme…
431
- * @example
432
- * import { useCodenotch } from 'codenotch-react';
433
- *
434
- * const MyApp = () => {
435
- * const cn = useCodenotch();
436
- * return <h1>{cn.i18n('welcome')}</h1>;
437
- * };
438
345
  */
439
346
  function useCodenotch() {
440
347
  return (0, react_1.useSyncExternalStore)(subscribe, getCodenotch, getCodenotch);
@@ -468,21 +375,6 @@ function onCodenotchChange(listener) {
468
375
  *
469
376
  * @param Component A component whose props extend {@link WithCodenotchProps}.
470
377
  * @returns A component with the same props minus `cn`.
471
- * @example
472
- * import { withCodenotch, WithCodenotchProps } from 'codenotch-react';
473
- *
474
- * interface Props extends WithCodenotchProps {
475
- * userId: string;
476
- * }
477
- *
478
- * class TodoList extends React.Component<Props> {
479
- * render() {
480
- * return <h1>{this.props.cn.i18n('todos.title')}</h1>;
481
- * }
482
- * }
483
- *
484
- * export default withCodenotch(TodoList);
485
- * // <TodoList userId="42" /> — `cn` is injected
486
378
  */
487
379
  function withCodenotch(Component) {
488
380
  const Wrapped = (props) => {
@@ -493,10 +385,6 @@ function withCodenotch(Component) {
493
385
  Wrapped.displayName = `withCodenotch(${Component.displayName || Component.name || "Component"})`;
494
386
  return Wrapped;
495
387
  }
496
- // Public models. Re-exported from the package root so that the typings
497
- // generated by the Codenotch IDE (typings/i18n.d.ts and typings/process.d.ts,
498
- // which augment the 'codenotch-react' module) merge with the real
499
- // TranslationRegistry / ProcessRegistry declarations.
500
388
  __exportStar(require("./models/Codenotch"), exports);
501
389
  __exportStar(require("./models/Misc"), exports);
502
390
  __exportStar(require("@codenotch/codenotch.core"), exports);
@@ -1,6 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import { ProjectManifest, IAppManifest } from "@codenotch/codenotch.core";
3
- import { ICodenotchSignal, IDisposable } from "./Misc";
2
+ import { IAppManifest, ICodenotchProjectManifest } from "@codenotch/codenotch.core";
4
3
  /**
5
4
  * Runtime environment of a Codenotch application.
6
5
  *
@@ -20,92 +19,17 @@ export interface ICodenotchEnv {
20
19
  accessToken?: string;
21
20
  /** Base URL of the current application. */
22
21
  baseUrl?: string;
23
- /** Translation dictionaries, keyed by language then by translation key: `i18n[language][key] = text`. */
24
- i18n?: {
25
- [language: string]: {
26
- [key: string]: string;
27
- };
28
- };
29
- /** Current language code (e.g. `"en"`). Defaults to the first language found in {@link i18n}. */
22
+ /** Current language code (e.g. `"en"`). */
30
23
  language?: string;
31
24
  /** Current UI theme. Resolved from the `_theme` URL parameter, or `prefers-color-scheme` as a fallback. */
32
25
  theme?: 'light' | 'dark';
33
26
  /** Manifest of the current application (the `<AppName>.manifest.json` file next to the app). */
34
27
  appManifest?: IAppManifest;
35
28
  /** Manifest of the Codenotch project (the project's `manifest.json` file). */
36
- projectManifest?: ProjectManifest;
29
+ projectManifest?: ICodenotchProjectManifest;
37
30
  /** Any additional environment variable passed to `init()`. */
38
31
  [key: string]: any;
39
32
  }
40
- /**
41
- * Registry of the project's BPMN processes, used to type {@link ICodenotchApi.startProcess}.
42
- *
43
- * Empty by default: the Codenotch IDE fills it through declaration merging in the
44
- * auto-generated `typings/process.d.ts` file of each project, with one entry per
45
- * BPMN process. Each entry maps the process name to its start events (`nodes`,
46
- * keyed by start node id, valued with the start event's input parameters) and to
47
- * the `output` of its end event.
48
- *
49
- * When the registry has not been augmented (project built without the IDE
50
- * typings), `startProcess` falls back to plain string names and untyped inputs,
51
- * so the code still compiles.
52
- *
53
- * @example
54
- * // typings/process.d.ts (auto-generated by the Codenotch IDE)
55
- * import 'codenotch-react';
56
- * declare module 'codenotch-react' {
57
- * interface ProcessRegistry {
58
- * 'getTodos': {
59
- * nodes: { 'start': { UserId: string } };
60
- * output: { todos: any[] };
61
- * };
62
- * }
63
- * }
64
- */
65
- export interface ProcessRegistry {
66
- }
67
- /**
68
- * Registry of the project's translation keys, used to type {@link ICodenotchApi.i18n}.
69
- *
70
- * Empty by default: the Codenotch IDE fills it through declaration merging in the
71
- * auto-generated `typings/i18n.d.ts` file of each project, from the project's
72
- * `.i18n.csv` files. Each entry maps a translation key to the tuple of arguments
73
- * expected by its `{0}`, `{1}`, … placeholders.
74
- *
75
- * When the registry has not been augmented (project built without the IDE
76
- * typings), `i18n` falls back to plain string keys and untyped arguments,
77
- * so the code still compiles.
78
- *
79
- * @example
80
- * // typings/i18n.d.ts (auto-generated by the Codenotch IDE)
81
- * import 'codenotch-react';
82
- * declare module 'codenotch-react' {
83
- * interface TranslationRegistry {
84
- * 'welcome': [];
85
- * 'greeting': [arg1: any, arg2: any];
86
- * }
87
- * }
88
- */
89
- export interface TranslationRegistry {
90
- }
91
- /** A BPMN process name: a key of {@link ProcessRegistry}, or any string when the registry is empty. */
92
- export type ProcessName = keyof ProcessRegistry extends never ? string : keyof ProcessRegistry;
93
- /** The start nodes of process `P`: its `nodes` map from {@link ProcessRegistry}, or an open map when unknown. */
94
- export type ProcessNodes<P> = P extends keyof ProcessRegistry ? ProcessRegistry[P] extends {
95
- nodes: infer N;
96
- } ? N : {
97
- [nodeId: string]: any;
98
- } : {
99
- [nodeId: string]: any;
100
- };
101
- /** The end-event output of process `P` from {@link ProcessRegistry}, or `any` when unknown. */
102
- export type ProcessOutput<P> = P extends keyof ProcessRegistry ? ProcessRegistry[P] extends {
103
- output: infer O;
104
- } ? O : any : any;
105
- /** A translation key: a key of {@link TranslationRegistry}, or any string when the registry is empty. */
106
- export type TranslationKey = keyof TranslationRegistry extends never ? string : keyof TranslationRegistry;
107
- /** The placeholder arguments of translation key `K` from {@link TranslationRegistry}, or `any[]` when unknown. */
108
- export type TranslationArgs<K> = K extends keyof TranslationRegistry ? TranslationRegistry[K] extends any[] ? TranslationRegistry[K] : any[] : any[];
109
33
  /**
110
34
  * Result of a BPMN process execution started with {@link ICodenotchApi.startProcess}.
111
35
  */
@@ -127,46 +51,15 @@ export interface IProcessResult<T = any> {
127
51
  * plain `getCodenotch()` function anywhere else (handlers, modules, services).
128
52
  *
129
53
  * It is the bridge between a React app and the Codenotch runtime: it starts
130
- * server-side BPMN processes, runs CNQL queries, translates i18n keys,
54
+ * server-side BPMN processes, runs CNQL queries,
131
55
  * listens to real-time signals and manages theme/language.
132
- *
133
- * @example
134
- * import { useCodenotch } from 'codenotch-react';
135
- *
136
- * const cn = useCodenotch();
137
- * const title = cn.i18n('welcome');
138
- * const result = await cn.startProcess('getTodos', 'start', { UserId: '42' });
139
56
  */
140
57
  export interface ICodenotchApi {
141
58
  /**
142
59
  * Start a server-side BPMN process and wait for its completion.
143
- *
144
- * @param processName Name of the process — the `.bpmn` file name without extension (e.g. `processes/getTodos.bpmn` → `'getTodos'`).
145
- * @param startNodeId Id of the start event to trigger (conventionally `'start'`).
146
- * @param inputs Input parameters declared by that start event.
147
- * @returns The process result; check `isError` before using `output` (the parameters of the end event reached).
148
- * @example
149
- * const result = await cn.startProcess('getTodos', 'start', { UserId: userId });
150
- * if (!result.isError) {
151
- * setTodos(result.output.todos);
152
- * }
153
- */
154
- startProcess<P extends ProcessName, N extends keyof ProcessNodes<P>>(processName: P, startNodeId: N, inputs: ProcessNodes<P>[N]): Promise<IProcessResult<ProcessOutput<P>>>;
155
- /**
156
- * Translate a key for the current language ({@link ICodenotchEnv.language}).
157
- *
158
- * Placeholders `{0}`, `{1}`, … in the translated text are replaced by `args`.
159
- * Never throws: if the key or the language is missing, a warning is logged
160
- * and the key itself is returned.
161
- *
162
- * @param key Translation key, as defined in the project's `.i18n.csv` files.
163
- * @param args Values for the `{0}`, `{1}`, … placeholders of the translation.
164
- * @example
165
- * cn.i18n('welcome'); // "Bienvenue"
166
- * cn.i18n('greeting', 'Fabian', 3); // "Bonjour Fabian, 3 messages" (from "Bonjour {0}, {1} messages")
167
60
  */
168
- i18n<K extends TranslationKey>(key: K, ...args: TranslationArgs<K>): string;
169
- /** Runtime environment (cluster, service, language, theme, i18n dictionaries, manifests…). Populated by `init()`. */
61
+ startProcess<TProcess, TInput, TOutput>(process: TProcess, inputs: TInput): Promise<IProcessResult<TOutput>>;
62
+ /** Runtime environment (cluster, service, language, theme dictionaries, manifests…). Populated by `init()`. */
170
63
  readonly env: ICodenotchEnv;
171
64
  /**
172
65
  * Execute a CNQL query (XML, SELECT-only) against the project's SQL tables and return the parsed JSON result.
@@ -213,25 +106,11 @@ export interface ICodenotchApi {
213
106
  * @param relativePath Path of the file relative to the project root.
214
107
  */
215
108
  readonly getProjectFileUrl: (relativePath: string) => string;
216
- /**
217
- * Subscribe to a real-time signal emitted by the project's BPMN processes (via SignalR).
218
- *
219
- * @param signalId Id of the signal, as declared in the BPMN process.
220
- * @param callback Called each time the signal is received, with `{ signalId, data }`.
221
- * @returns A disposable — call `dispose()` to unsubscribe (e.g. in a `useEffect` cleanup).
222
- * @example
223
- * useEffect(() => {
224
- * let sub: IDisposable | undefined;
225
- * cn.listenSignal('todosChanged', () => refresh()).then(s => sub = s);
226
- * return () => sub?.dispose();
227
- * }, []);
228
- */
229
- readonly listenSignal: (signalId: string, callback: (data: ICodenotchSignal) => void) => Promise<IDisposable>;
230
109
  /** Set the UI theme. Also toggles the `light`/`dark` class on `<html>` (Tailwind `dark:` variants). */
231
110
  readonly setTheme: (theme: 'light' | 'dark') => void;
232
111
  /** Current UI theme, if resolved. */
233
112
  readonly getTheme: () => 'light' | 'dark' | undefined;
234
- /** Set the current language used by {@link i18n}. Must be one of the project's languages. */
113
+ /** Set the current language. Must be one of the project's languages. */
235
114
  readonly setLanguage: (lang: string) => void;
236
115
  /** Current language code, if any. */
237
116
  readonly getLanguage: () => string | undefined;
@@ -244,7 +123,7 @@ export interface ICodenotchApi {
244
123
  /** Generate a random UUID v4. */
245
124
  readonly uuid: () => string;
246
125
  /** Manifest of the Codenotch project. Throws if not available in the environment. */
247
- readonly getProjectManifest: () => ProjectManifest;
126
+ readonly getProjectManifest: () => ICodenotchProjectManifest;
248
127
  /** Manifest of the current application, if any. */
249
128
  readonly getAppManifest: () => IAppManifest | undefined;
250
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Codenotch.d.ts","sourceRoot":"","sources":["../../src/models/Codenotch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,gBAA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AAuG;IACvG,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;IACrD,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACtD,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,qCAAqC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC/C,2DAA2D;IAC3D,QAAQ,CAAC,YAAY,EAAE,MAAM,MAAM,EAAE,CAAC;IACtC,4GAA4G;IAC5G,QAAQ,CAAC,YAAY,EAAE,MAAM;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvD,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;IAC7D,mDAAmD;IACnD,QAAQ,CAAC,cAAc,EAAE,MAAM,YAAY,GAAG,SAAS,CAAC;CAC3D;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAC/B,4FAA4F;IAC5F,EAAE,EAAE,aAAa,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,KAAK,EAAE,MAAM,IAAI,CAAC;CACrB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codenotch/codenotch.react",
3
- "version": "2.0.0",
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.",
3
+ "version": "2.0.1",
4
+ "description": "React bindings for Codenotch applications: start BPMN processes, run cnql queries, listen to real-time signals, manage theme and language.",
5
5
  "keywords": [
6
6
  "codenotch",
7
7
  "react"
@@ -25,8 +25,7 @@
25
25
  "src/**/*"
26
26
  ],
27
27
  "dependencies": {
28
- "@codenotch/codenotch.core": "1.0.21",
29
- "@microsoft/signalr": "^5.0.6",
28
+ "@codenotch/codenotch.core": "1.0.23",
30
29
  "uuid": "^8.2.0"
31
30
  },
32
31
  "devDependencies": {