@adcops/autocore-react 3.5.7 → 3.5.11
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/components/forms/useEditDraft.d.ts +49 -0
- package/dist/components/forms/useEditDraft.d.ts.map +1 -0
- package/dist/components/forms/useEditDraft.js +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/tis/TestDataView.d.ts +8 -0
- package/dist/components/tis/TestDataView.d.ts.map +1 -1
- package/dist/components/tis/TestDataView.js +1 -1
- package/dist/components/tis/TestRawDataView.d.ts.map +1 -1
- package/dist/components/tis/TestRawDataView.js +1 -1
- package/dist/components/tis/chartViews.d.ts +57 -0
- package/dist/components/tis/chartViews.d.ts.map +1 -0
- package/dist/components/tis/chartViews.js +1 -0
- package/dist/components/tis-editor/TisConfigEditor.css +11 -0
- package/dist/components/tis-editor/TisConfigEditor.d.ts.map +1 -1
- package/dist/components/tis-editor/TisConfigEditor.js +1 -1
- package/dist/components/tis-editor/editor/AuthoringContext.d.ts +37 -0
- package/dist/components/tis-editor/editor/AuthoringContext.d.ts.map +1 -0
- package/dist/components/tis-editor/editor/AuthoringContext.js +1 -0
- package/dist/components/tis-editor/editor/ChartViewDialog.d.ts +11 -0
- package/dist/components/tis-editor/editor/ChartViewDialog.d.ts.map +1 -1
- package/dist/components/tis-editor/editor/ChartViewDialog.js +1 -1
- package/dist/components/tis-editor/editor/FieldArrayEditor.d.ts.map +1 -1
- package/dist/components/tis-editor/editor/FieldArrayEditor.js +1 -1
- package/dist/components/tis-editor/editor/RawDataEditor.d.ts.map +1 -1
- package/dist/components/tis-editor/editor/RawDataEditor.js +1 -1
- package/dist/components/tis-editor/editor/TestFieldDialog.d.ts +7 -0
- package/dist/components/tis-editor/editor/TestFieldDialog.d.ts.map +1 -1
- package/dist/components/tis-editor/editor/TestFieldDialog.js +1 -1
- package/dist/components/tis-editor/editor/ViewsEditor.d.ts.map +1 -1
- package/dist/components/tis-editor/editor/ViewsEditor.js +1 -1
- package/dist/components/tis-editor/types.d.ts +6 -0
- package/dist/components/tis-editor/types.d.ts.map +1 -1
- package/dist/components/varpick/VariableInput.d.ts +41 -0
- package/dist/components/varpick/VariableInput.d.ts.map +1 -0
- package/dist/components/varpick/VariableInput.js +1 -0
- package/dist/components/varpick/VariablePicker.d.ts +45 -0
- package/dist/components/varpick/VariablePicker.d.ts.map +1 -0
- package/dist/components/varpick/VariablePicker.js +1 -0
- package/dist/components/varpick/index.d.ts +16 -0
- package/dist/components/varpick/index.d.ts.map +1 -0
- package/dist/components/varpick/index.js +1 -0
- package/dist/components/varpick/tisCatalogs.d.ts +85 -0
- package/dist/components/varpick/tisCatalogs.d.ts.map +1 -0
- package/dist/components/varpick/tisCatalogs.js +1 -0
- package/dist/components/varpick/varpick.css +167 -0
- package/dist/core/AutoCoreTagContext.d.ts.map +1 -1
- package/dist/core/AutoCoreTagContext.js +1 -1
- package/dist/core/AutoCoreTagTypes.d.ts +13 -0
- package/dist/core/AutoCoreTagTypes.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useGmVariables.d.ts +57 -0
- package/dist/hooks/useGmVariables.d.ts.map +1 -0
- package/dist/hooks/useGmVariables.js +1 -0
- package/dist/hooks/useSequenceProducers.d.ts +38 -0
- package/dist/hooks/useSequenceProducers.d.ts.map +1 -0
- package/dist/hooks/useSequenceProducers.js +1 -0
- package/package.json +7 -2
- package/src/components/forms/useEditDraft.ts +0 -0
- package/src/components/index.ts +20 -0
- package/src/components/tis/TestDataView.tsx +16 -10
- package/src/components/tis/TestRawDataView.tsx +6 -7
- package/src/components/tis/chartViews.ts +104 -0
- package/src/components/tis-editor/TisConfigEditor.css +11 -0
- package/src/components/tis-editor/TisConfigEditor.tsx +31 -0
- package/src/components/tis-editor/editor/AuthoringContext.tsx +43 -0
- package/src/components/tis-editor/editor/ChartViewDialog.tsx +48 -17
- package/src/components/tis-editor/editor/FieldArrayEditor.tsx +1 -0
- package/src/components/tis-editor/editor/RawDataEditor.tsx +7 -2
- package/src/components/tis-editor/editor/TestFieldDialog.tsx +90 -23
- package/src/components/tis-editor/editor/ViewsEditor.tsx +56 -5
- package/src/components/tis-editor/types.ts +6 -0
- package/src/components/varpick/VariableInput.tsx +126 -0
- package/src/components/varpick/VariablePicker.tsx +168 -0
- package/src/components/varpick/index.ts +22 -0
- package/src/components/varpick/tisCatalogs.ts +235 -0
- package/src/components/varpick/varpick.css +167 -0
- package/src/core/AutoCoreTagContext.tsx +3 -1
- package/src/core/AutoCoreTagTypes.ts +14 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/useGmVariables.ts +142 -0
- package/src/hooks/useSequenceProducers.ts +104 -0
- package/tools/tests/dist/TestFieldDialog-C4mKVh7q.js +32817 -0
- package/tools/tests/dist/autocore-react.css +257 -0
- package/tools/tests/dist/tis-editor.entry.js +9295 -0
- package/tools/tests/dist/varpick.entry.js +113 -0
- package/tools/tests/live-server.probe.mjs +172 -0
- package/tools/tests/tis-editor.entry.tsx +46 -0
- package/tools/tests/tis-editor.test.mjs +133 -0
- package/tools/tests/varpick.entry.tsx +81 -0
- package/tools/tests/varpick.test.mjs +208 -0
- package/tools/tests/vite.config.mjs +35 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSequenceProducers — the names a method's sequence actually records.
|
|
3
|
+
*
|
|
4
|
+
* A TIS cycle field has two possible producers and the method editor could only
|
|
5
|
+
* ever see one of them:
|
|
6
|
+
*
|
|
7
|
+
* 1. `source: "gm.<var>"` — the generated `add_cycle()` reads the tag.
|
|
8
|
+
* 2. `source: null` — the value arrives with the row, matched by NAME. On
|
|
9
|
+
* gen4_ac that is the sequencer: `store_value` steps fill a row buffer and
|
|
10
|
+
* `tis.add_cycle` writes `cycle_data` verbatim, without checking it against
|
|
11
|
+
* `cycle_fields`.
|
|
12
|
+
*
|
|
13
|
+
* Because nothing checks the second one, both of its failure modes are silent:
|
|
14
|
+
* a declared column nothing stores is blank on every row forever, and a stored
|
|
15
|
+
* name with no column is recorded where nothing displays it. This hook reads
|
|
16
|
+
* the `.seq.json` so the editor can say so.
|
|
17
|
+
*
|
|
18
|
+
* The method id IS the sequence filename and the TIS method id — one name, set
|
|
19
|
+
* by the sequence workbench's New / Save As / Open. A product with no sequencer
|
|
20
|
+
* simply has no such file, which is why "could not read it" resolves to
|
|
21
|
+
* `undefined` and never to `[]`: an empty list would claim every cycle field
|
|
22
|
+
* has no producer.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
26
|
+
import { EventEmitterContext } from '../core/EventEmitterContext';
|
|
27
|
+
import { MessageType } from '../hub/CommandMessage';
|
|
28
|
+
|
|
29
|
+
/** Where the sequence library lives in the datastore. */
|
|
30
|
+
const METHOD_DIR = 'methods';
|
|
31
|
+
const METHOD_EXT = '.seq.json';
|
|
32
|
+
|
|
33
|
+
export interface UseSequenceProducersOptions {
|
|
34
|
+
/** Override the IPC layer (tests, playground). */
|
|
35
|
+
invoker?: (topic: string, messageType: number, payload: object) => Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface UseSequenceProducersResult {
|
|
39
|
+
/** `store_value` names, or `undefined` when there is no sequence to read. */
|
|
40
|
+
producedNames: string[] | undefined;
|
|
41
|
+
loading: boolean;
|
|
42
|
+
refresh: () => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Every `store_value` name in a method, `cycle` bodies included. */
|
|
46
|
+
export function collectStoredNames(method: any): string[] {
|
|
47
|
+
const out: string[] = [];
|
|
48
|
+
const walk = (steps: any[]) => {
|
|
49
|
+
if (!Array.isArray(steps)) return;
|
|
50
|
+
for (const s of steps) {
|
|
51
|
+
if (!s || typeof s !== 'object') continue;
|
|
52
|
+
if (s.type === 'cycle') walk(s.body);
|
|
53
|
+
// A repeated measurement lives inside a `cycle` body, so a walk that
|
|
54
|
+
// stopped at the top level would miss exactly the methods that
|
|
55
|
+
// record the most.
|
|
56
|
+
if (s.type === 'store_value' && typeof s.name === 'string' && s.name.trim() !== '') {
|
|
57
|
+
if (!out.includes(s.name)) out.push(s.name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
walk(method?.steps);
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function useSequenceProducers(
|
|
66
|
+
methodId: string | null,
|
|
67
|
+
options?: UseSequenceProducersOptions,
|
|
68
|
+
): UseSequenceProducersResult {
|
|
69
|
+
const ctx = useContext(EventEmitterContext);
|
|
70
|
+
const invoke = options?.invoker
|
|
71
|
+
?? ((topic: string, messageType: number, payload: object) =>
|
|
72
|
+
ctx.invoke(topic as any, messageType as any, payload as any));
|
|
73
|
+
|
|
74
|
+
const invokeRef = useRef(invoke);
|
|
75
|
+
invokeRef.current = invoke;
|
|
76
|
+
|
|
77
|
+
const [producedNames, setProducedNames] = useState<string[] | undefined>(undefined);
|
|
78
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
79
|
+
|
|
80
|
+
const refresh = useCallback(async () => {
|
|
81
|
+
if (!methodId) { setProducedNames(undefined); return; }
|
|
82
|
+
setLoading(true);
|
|
83
|
+
try {
|
|
84
|
+
const topic = `datastore.${METHOD_DIR}/${methodId}${METHOD_EXT}`;
|
|
85
|
+
const resp: any = await invokeRef.current(topic, MessageType.Read, {});
|
|
86
|
+
if (resp?.success === false) { setProducedNames(undefined); return; }
|
|
87
|
+
const method = resp?.data ?? resp;
|
|
88
|
+
// Only a method-shaped object counts. A read that returns something
|
|
89
|
+
// else is "no sequence", not "a sequence storing nothing".
|
|
90
|
+
if (!method || !Array.isArray(method.steps)) { setProducedNames(undefined); return; }
|
|
91
|
+
setProducedNames(collectStoredNames(method));
|
|
92
|
+
} catch {
|
|
93
|
+
setProducedNames(undefined);
|
|
94
|
+
} finally {
|
|
95
|
+
setLoading(false);
|
|
96
|
+
}
|
|
97
|
+
}, [methodId]);
|
|
98
|
+
|
|
99
|
+
useEffect(() => { void refresh(); }, [refresh]);
|
|
100
|
+
|
|
101
|
+
return { producedNames, loading, refresh };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default useSequenceProducers;
|