@j2inn/fin5-ui-utils 0.0.2 → 0.0.5-beta.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.
Files changed (113) hide show
  1. package/dist/fantomProps/createFin5Props/index.d.ts +12 -0
  2. package/dist/fantomProps/createFin5Props/index.js +147 -0
  3. package/dist/fantomProps/createFin5Props/index.js.map +1 -0
  4. package/dist/fantomProps/createFin5Props/runCreateFin5Props.d.ts +2 -0
  5. package/dist/fantomProps/createFin5Props/runCreateFin5Props.js +17 -0
  6. package/dist/fantomProps/createFin5Props/runCreateFin5Props.js.map +1 -0
  7. package/dist/fantomProps/fantomPropsToObject.js +3 -0
  8. package/dist/fantomProps/fantomPropsToObject.js.map +1 -1
  9. package/dist/fantomProps/generateJsonFromFantomPropsFile.js +3 -0
  10. package/dist/fantomProps/generateJsonFromFantomPropsFile.js.map +1 -1
  11. package/dist/fantomProps/localePropsToJson.js +3 -0
  12. package/dist/fantomProps/localePropsToJson.js.map +1 -1
  13. package/dist/fantomProps/readFantomPropsFile.js +3 -0
  14. package/dist/fantomProps/readFantomPropsFile.js.map +1 -1
  15. package/dist/fin5Top/fin5Top.js +3 -0
  16. package/dist/fin5Top/fin5Top.js.map +1 -1
  17. package/dist/fin5Top/getFin5BinUrl.js +3 -0
  18. package/dist/fin5Top/getFin5BinUrl.js.map +1 -1
  19. package/dist/fin5Top/openFin5Alarm.js +5 -2
  20. package/dist/fin5Top/openFin5Alarm.js.map +1 -1
  21. package/dist/fin5Top/openFin5Historian.js +5 -2
  22. package/dist/fin5Top/openFin5Historian.js.map +1 -1
  23. package/dist/fin5Top/useFin5AppURLHashParameter.d.ts +7 -0
  24. package/dist/fin5Top/useFin5AppURLHashParameter.js +72 -0
  25. package/dist/fin5Top/useFin5AppURLHashParameter.js.map +1 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/index.js +12 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/react/app/Fin5AppContainer.d.ts +36 -0
  30. package/dist/react/app/Fin5AppContainer.jsx +102 -0
  31. package/dist/react/app/Fin5AppContainer.jsx.map +1 -0
  32. package/dist/react/app/Fin5AppRootStore.d.ts +38 -0
  33. package/dist/react/app/Fin5AppRootStore.js +66 -0
  34. package/dist/react/app/Fin5AppRootStore.js.map +1 -0
  35. package/dist/react/components/ErrorBoundary.d.ts +57 -0
  36. package/dist/react/components/ErrorBoundary.jsx +177 -0
  37. package/dist/react/components/ErrorBoundary.jsx.map +1 -0
  38. package/dist/react/components/Loader.d.ts +9 -0
  39. package/dist/react/components/Loader.jsx +18 -0
  40. package/dist/react/components/Loader.jsx.map +1 -0
  41. package/dist/react/components/LoadingSpinner.jsx +19 -3
  42. package/dist/react/components/LoadingSpinner.jsx.map +1 -1
  43. package/dist/react/components/navigation/BasicLayout.d.ts +2 -1
  44. package/dist/react/components/navigation/BasicLayout.jsx +10 -3
  45. package/dist/react/components/navigation/BasicLayout.jsx.map +1 -1
  46. package/dist/react/components/navigation/MenuPage.jsx +3 -0
  47. package/dist/react/components/navigation/MenuPage.jsx.map +1 -1
  48. package/dist/react/components/navigation/Router.jsx +3 -0
  49. package/dist/react/components/navigation/Router.jsx.map +1 -1
  50. package/dist_es/fantomProps/createFin5Props/index.d.ts +12 -0
  51. package/dist_es/fantomProps/createFin5Props/index.js +141 -0
  52. package/dist_es/fantomProps/createFin5Props/index.js.map +1 -0
  53. package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.d.ts +2 -0
  54. package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.js +12 -0
  55. package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.js.map +1 -0
  56. package/dist_es/fantomProps/fantomPropsToObject.d.ts +8 -0
  57. package/dist_es/fantomProps/fantomPropsToObject.js +179 -0
  58. package/dist_es/fantomProps/fantomPropsToObject.js.map +1 -0
  59. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.d.ts +4 -0
  60. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js +13 -0
  61. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js.map +1 -0
  62. package/dist_es/fantomProps/localePropsToJson.d.ts +1 -0
  63. package/dist_es/fantomProps/localePropsToJson.js +22 -0
  64. package/dist_es/fantomProps/localePropsToJson.js.map +1 -0
  65. package/dist_es/fantomProps/readFantomPropsFile.d.ts +5 -0
  66. package/dist_es/fantomProps/readFantomPropsFile.js +36 -0
  67. package/dist_es/fantomProps/readFantomPropsFile.js.map +1 -0
  68. package/dist_es/fin5Top/fin5Top.d.ts +111 -0
  69. package/dist_es/fin5Top/fin5Top.js +55 -0
  70. package/dist_es/fin5Top/fin5Top.js.map +1 -0
  71. package/dist_es/fin5Top/getFin5BinUrl.d.ts +2 -0
  72. package/dist_es/fin5Top/getFin5BinUrl.js +6 -0
  73. package/dist_es/fin5Top/getFin5BinUrl.js.map +1 -0
  74. package/dist_es/fin5Top/openFin5Alarm.d.ts +22 -0
  75. package/dist_es/fin5Top/openFin5Alarm.js +20 -0
  76. package/dist_es/fin5Top/openFin5Alarm.js.map +1 -0
  77. package/dist_es/fin5Top/openFin5Historian.d.ts +3 -0
  78. package/dist_es/fin5Top/openFin5Historian.js +16 -0
  79. package/dist_es/fin5Top/openFin5Historian.js.map +1 -0
  80. package/dist_es/fin5Top/useFin5AppURLHashParameter.d.ts +7 -0
  81. package/dist_es/fin5Top/useFin5AppURLHashParameter.js +68 -0
  82. package/dist_es/fin5Top/useFin5AppURLHashParameter.js.map +1 -0
  83. package/dist_es/index.d.ts +18 -0
  84. package/dist_es/index.js +34 -0
  85. package/dist_es/index.js.map +1 -0
  86. package/dist_es/react/app/Fin5AppContainer.d.ts +36 -0
  87. package/dist_es/react/app/Fin5AppContainer.jsx +73 -0
  88. package/dist_es/react/app/Fin5AppContainer.jsx.map +1 -0
  89. package/dist_es/react/app/Fin5AppRootStore.d.ts +38 -0
  90. package/dist_es/react/app/Fin5AppRootStore.js +62 -0
  91. package/dist_es/react/app/Fin5AppRootStore.js.map +1 -0
  92. package/dist_es/react/components/ErrorBoundary.d.ts +57 -0
  93. package/dist_es/react/components/ErrorBoundary.jsx +150 -0
  94. package/dist_es/react/components/ErrorBoundary.jsx.map +1 -0
  95. package/dist_es/react/components/ErrorDisplayer.d.ts +19 -0
  96. package/dist_es/react/components/ErrorDisplayer.jsx +36 -0
  97. package/dist_es/react/components/ErrorDisplayer.jsx.map +1 -0
  98. package/dist_es/react/components/Loader.d.ts +9 -0
  99. package/dist_es/react/components/Loader.jsx +13 -0
  100. package/dist_es/react/components/Loader.jsx.map +1 -0
  101. package/dist_es/react/components/LoadingSpinner.d.ts +3 -0
  102. package/dist_es/react/components/LoadingSpinner.jsx +23 -0
  103. package/dist_es/react/components/LoadingSpinner.jsx.map +1 -0
  104. package/dist_es/react/components/navigation/BasicLayout.d.ts +21 -0
  105. package/dist_es/react/components/navigation/BasicLayout.jsx +104 -0
  106. package/dist_es/react/components/navigation/BasicLayout.jsx.map +1 -0
  107. package/dist_es/react/components/navigation/MenuPage.d.ts +33 -0
  108. package/dist_es/react/components/navigation/MenuPage.jsx +31 -0
  109. package/dist_es/react/components/navigation/MenuPage.jsx.map +1 -0
  110. package/dist_es/react/components/navigation/Router.d.ts +12 -0
  111. package/dist_es/react/components/navigation/Router.jsx +19 -0
  112. package/dist_es/react/components/navigation/Router.jsx.map +1 -0
  113. package/package.json +22 -11
@@ -1 +1 @@
1
- {"version":3,"file":"Router.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/Router.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAMc;AACd,uEAA8C;AAC9C,yCAAqD;AASrD;;GAEG;AACH,SAAgB,MAAM,CAAqB,EAC1C,KAAK,GAAG,EAAE,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GACkB;IACnC,MAAM,IAAI,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,IAAA,yBAAc,EAAC,KAAK,EAAE,WAAW,CAAC,EACxC,CA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D,EAAG,CAAC,CACtC;GAAA,CAAC,eAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAClD;EAAA,EAAE,gBAAQ,CAAC,CACX,CAAC,CAAC,CAAC,CACH,iBAAiB,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,CAAE,eAAc,EAAE,GAAG,CAAC,CAC5D,CAAA;AACF,CAAC;AAtBD,wBAsBC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Create the FIN5 language prop files from the locale JSON files.
3
+ *
4
+ * This function assumes the app directory has a sub-directory named `locale` that contains
5
+ * the language files in a JSON format (i.e. `en.json`). It also assumes there's a `lib` directory
6
+ * containing the defs for the app. This is used to look up the app name that's used to prefix the
7
+ * entries in the properties file.
8
+ *
9
+ * @param appDir The directory that contains the application.
10
+ * @param propsDir The directory the properties file will output too.
11
+ */
12
+ export default function createFin5Props(appDir: string, propsDir: string): Promise<void>;
@@ -0,0 +1,141 @@
1
+ /*
2
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
+ */
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import yaml from 'js-yaml';
7
+ import { promisify } from 'util';
8
+ import { makeValue, HNamespace } from 'haystack-core';
9
+ const readFile = promisify(fs.readFile);
10
+ const writeFile = promisify(fs.writeFile);
11
+ const exists = promisify(fs.exists);
12
+ const mkdir = promisify(fs.mkdir);
13
+ const readdir = promisify(fs.readdir);
14
+ const unlink = promisify(fs.unlink);
15
+ /**
16
+ * The FIN locale path where all the JSON files reside.
17
+ */
18
+ const LOCALE_PATH = 'locale';
19
+ /**
20
+ * The application defs YAML file path.
21
+ */
22
+ const APP_DEF_YAML = 'lib/app.hayson.yaml';
23
+ /**
24
+ * Return the app name.
25
+ *
26
+ * @param baseDir The base directory to run from.
27
+ * @returns The name of the app.
28
+ */
29
+ async function getAppName(baseDir) {
30
+ const buffer = await readFile(path.join(baseDir, APP_DEF_YAML));
31
+ // Find the name of the app to prefix all the keys with.
32
+ const appHayson = yaml.loadAll(buffer.toString('utf8'))?.[0];
33
+ const value = makeValue(appHayson);
34
+ return HNamespace.getFeatureName(value.get('def')?.value ?? '');
35
+ }
36
+ /**
37
+ * Return the language from the file path.
38
+ *
39
+ * @param path The file path.
40
+ * @return The language.
41
+ */
42
+ function getLanguageFromFile(path) {
43
+ return /^([^.]+)/.exec(path)?.[1] ?? '';
44
+ }
45
+ /**
46
+ * Build a tree of nodes.
47
+ *
48
+ * @param parent The parent to add the nodes too.
49
+ * @param obj The object to example.
50
+ * @param leads An array of leaf nodes to build up.
51
+ */
52
+ function buildNode(parent, obj, leafs) {
53
+ for (const key of Object.keys(obj)) {
54
+ const child = { name: key, parent };
55
+ const value = obj[key];
56
+ if (typeof value === 'string') {
57
+ child.value = value;
58
+ leafs.push(child);
59
+ }
60
+ else {
61
+ buildNode(child, value, leafs);
62
+ }
63
+ }
64
+ }
65
+ /**
66
+ * Create properties from the object.
67
+ *
68
+ * @param appName The application name.
69
+ * @param obj The object.
70
+ * @returns The properties.
71
+ */
72
+ function createProps(appName, obj) {
73
+ // Build a tree node of nodes for the JSON object. Record all the leafs.
74
+ const leafs = [];
75
+ buildNode({ name: appName }, obj, leafs);
76
+ let props = '';
77
+ // For each leaf, walk all the parents to build up a list of names.
78
+ // Reverse the list of names to create the entry.
79
+ for (const node of leafs) {
80
+ const pathNames = [];
81
+ let n = node;
82
+ while (n) {
83
+ if (n.name) {
84
+ pathNames.push(n.name);
85
+ }
86
+ n = n.parent;
87
+ }
88
+ if (pathNames.length) {
89
+ props += `${pathNames.reverse().join('.')}=${node.value}\n`;
90
+ }
91
+ }
92
+ return props;
93
+ }
94
+ /**
95
+ * Clean the properties directory of any properties files.
96
+ *
97
+ * @param dir The directory to check.
98
+ */
99
+ async function cleanPropsDir(dir) {
100
+ for (const file of await readdir(dir)) {
101
+ if (file.toLowerCase().endsWith('.props')) {
102
+ await unlink(path.join(dir, file));
103
+ }
104
+ }
105
+ }
106
+ /**
107
+ * Create the directory.
108
+ *
109
+ * @param dir The directory to create.
110
+ */
111
+ async function createDir(dir) {
112
+ if (!(await exists(dir))) {
113
+ await mkdir(dir, { recursive: true });
114
+ }
115
+ }
116
+ /**
117
+ * Create the FIN5 language prop files from the locale JSON files.
118
+ *
119
+ * This function assumes the app directory has a sub-directory named `locale` that contains
120
+ * the language files in a JSON format (i.e. `en.json`). It also assumes there's a `lib` directory
121
+ * containing the defs for the app. This is used to look up the app name that's used to prefix the
122
+ * entries in the properties file.
123
+ *
124
+ * @param appDir The directory that contains the application.
125
+ * @param propsDir The directory the properties file will output too.
126
+ */
127
+ export default async function createFin5Props(appDir, propsDir) {
128
+ const appName = await getAppName(appDir);
129
+ await createDir(propsDir);
130
+ await cleanPropsDir(propsDir);
131
+ // For each language file, create a properties file.
132
+ for (const file of await readdir(path.join(appDir, LOCALE_PATH))) {
133
+ const filePath = path.join(appDir, LOCALE_PATH, file);
134
+ const obj = JSON.parse((await readFile(filePath)).toString('utf8'));
135
+ const props = createProps(appName, obj);
136
+ const language = getLanguageFromFile(file);
137
+ const propFilePath = path.join(propsDir, `${language}.props`);
138
+ await writeFile(propFilePath, props);
139
+ }
140
+ }
141
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fantomProps/createFin5Props/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAA6B,MAAM,eAAe,CAAA;AAEhF,MAAM,QAAQ,GAAG,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;AACvC,MAAM,SAAS,GAAG,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAA;AACzC,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 #!/usr/bin/env node
2
+ import createFin5Props from '.';
3
+ import path from 'path';
4
+ /*
5
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
6
+ */
7
+ /**
8
+ * Run the creation of the FIN5 properties as a script.
9
+ */
10
+ console.log('Creating FIN5 property language files...');
11
+ createFin5Props(path.resolve(), path.resolve('locale')).then(() => console.log('Successfully completed property file creation'), (error) => console.error('Failed to create property file', error));
12
+ //# sourceMappingURL=runCreateFin5Props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runCreateFin5Props.js","sourceRoot":"","sources":["../../../src/fantomProps/createFin5Props/runCreateFin5Props.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,MAAM,GAAG,CAAA;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB;;GAEG;AAEH;;GAEG;AAEH,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;AACvD,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAC3D,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,EAClE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CACjE,CAAA"}
@@ -0,0 +1,8 @@
1
+ export interface Props {
2
+ [key: string]: string;
3
+ }
4
+ /**
5
+ * Convert the given fantom props as string to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
6
+ */
7
+ export default function fantomPropsToObject(props: string): Props;
8
+ export declare function parseFantomProps(readChar: () => number, unreadChar: (char: number) => void): Props;
@@ -0,0 +1,179 @@
1
+ /*
2
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
+ */
4
+ /**
5
+ * Convert the given fantom props as string to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
6
+ */
7
+ export default function fantomPropsToObject(props) {
8
+ let i = 0;
9
+ const readChar = () => {
10
+ if (i < props.length) {
11
+ i++;
12
+ return props.charCodeAt(i - 1);
13
+ }
14
+ else
15
+ return -1;
16
+ };
17
+ const unreadChar = () => {
18
+ if (i > 0) {
19
+ i--;
20
+ }
21
+ };
22
+ return parseFantomProps(readChar, unreadChar);
23
+ }
24
+ var UTF_8;
25
+ (function (UTF_8) {
26
+ UTF_8[UTF_8["tab"] = 9] = "tab";
27
+ UTF_8[UTF_8["lf"] = 10] = "lf";
28
+ UTF_8[UTF_8["cr"] = 13] = "cr";
29
+ UTF_8[UTF_8["space"] = 32] = "space";
30
+ UTF_8[UTF_8["numberSign"] = 35] = "numberSign";
31
+ UTF_8[UTF_8["asterisk"] = 42] = "asterisk";
32
+ UTF_8[UTF_8["solidus"] = 47] = "solidus";
33
+ UTF_8[UTF_8["equalSign"] = 61] = "equalSign";
34
+ UTF_8[UTF_8["reverseSolidus"] = 92] = "reverseSolidus";
35
+ UTF_8[UTF_8["n"] = 110] = "n";
36
+ UTF_8[UTF_8["r"] = 114] = "r";
37
+ UTF_8[UTF_8["t"] = 116] = "t";
38
+ UTF_8[UTF_8["u"] = 117] = "u";
39
+ })(UTF_8 || (UTF_8 = {}));
40
+ const isSpace = (char) => char === UTF_8.space ||
41
+ char === UTF_8.tab ||
42
+ char === UTF_8.lf ||
43
+ char === UTF_8.cr;
44
+ const hex = function (c) {
45
+ if (48 <= c && c <= 57)
46
+ return c - 48;
47
+ if (97 <= c && c <= 102)
48
+ return c - 97 + 10;
49
+ if (65 <= c && c <= 70)
50
+ return c - 65 + 10;
51
+ return -1;
52
+ };
53
+ /*
54
+ * Parse the Fantom props file character by character.
55
+ * Implementation based on https://github.com/fantom-lang/fantom/blob/master/src/sys/js/fan/InStream.js
56
+ */
57
+ export function parseFantomProps(readChar, unreadChar) {
58
+ const props = {};
59
+ let name = '';
60
+ let value = null;
61
+ let inBlockComment = 0;
62
+ let inEndOfLineComment = false;
63
+ let char = UTF_8.space, lastChar = UTF_8.space;
64
+ let lineNum = 1;
65
+ while (true) {
66
+ lastChar = char;
67
+ char = readChar();
68
+ if (char < 0)
69
+ break;
70
+ // end of line
71
+ if (char == UTF_8.lf || char == UTF_8.cr) {
72
+ inEndOfLineComment = false;
73
+ if (lastChar == UTF_8.cr && char == UTF_8.lf)
74
+ continue;
75
+ const n = name.trim();
76
+ if (value !== null) {
77
+ props[n] = value.trim();
78
+ name = '';
79
+ value = null;
80
+ }
81
+ else if (n.length > 0)
82
+ throw new Error('Invalid name/value pair [Line ' + lineNum + ']');
83
+ lineNum++;
84
+ continue;
85
+ }
86
+ // if in comment
87
+ if (inEndOfLineComment)
88
+ continue;
89
+ // block comment
90
+ if (inBlockComment > 0) {
91
+ if (lastChar == UTF_8.solidus && char == UTF_8.asterisk)
92
+ inBlockComment++;
93
+ if (lastChar == UTF_8.asterisk && char == UTF_8.solidus)
94
+ inBlockComment--;
95
+ continue;
96
+ }
97
+ // equal
98
+ if (char == UTF_8.equalSign && value === null) {
99
+ value = '';
100
+ continue;
101
+ }
102
+ // line comment
103
+ if (char === UTF_8.numberSign &&
104
+ (lastChar == UTF_8.lf || lastChar == UTF_8.cr)) {
105
+ inEndOfLineComment = true;
106
+ continue;
107
+ }
108
+ // end of line comment
109
+ if (char == UTF_8.solidus && isSpace(lastChar)) {
110
+ const peek = readChar();
111
+ if (peek < 0)
112
+ break;
113
+ if (peek == UTF_8.solidus) {
114
+ inEndOfLineComment = true;
115
+ continue;
116
+ }
117
+ if (peek == UTF_8.asterisk) {
118
+ inBlockComment++;
119
+ continue;
120
+ }
121
+ unreadChar(peek);
122
+ }
123
+ // escape or line continuation
124
+ if (char == UTF_8.reverseSolidus) {
125
+ let peek = readChar();
126
+ if (peek < 0)
127
+ break;
128
+ else if (peek == UTF_8.n)
129
+ char = UTF_8.lf;
130
+ else if (peek == UTF_8.r)
131
+ char = UTF_8.cr;
132
+ else if (peek == UTF_8.t)
133
+ char = UTF_8.tab;
134
+ else if (peek == UTF_8.reverseSolidus)
135
+ char = UTF_8.reverseSolidus;
136
+ else if (peek == UTF_8.cr || peek == UTF_8.lf) {
137
+ // line continuation
138
+ lineNum++;
139
+ if (peek == UTF_8.cr) {
140
+ peek = readChar();
141
+ if (peek != UTF_8.lf)
142
+ unreadChar(peek);
143
+ }
144
+ while (true) {
145
+ peek = readChar();
146
+ if (peek == UTF_8.space || peek == UTF_8.tab)
147
+ continue;
148
+ unreadChar(peek);
149
+ break;
150
+ }
151
+ continue;
152
+ }
153
+ else if (peek == UTF_8.u) {
154
+ const n3 = hex(readChar());
155
+ const n2 = hex(readChar());
156
+ const n1 = hex(readChar());
157
+ const n0 = hex(readChar());
158
+ if (n3 < 0 || n2 < 0 || n1 < 0 || n0 < 0)
159
+ throw new Error('Invalid hex value for \\uxxxx [Line ' + lineNum + ']');
160
+ char = (n3 << 12) | (n2 << 8) | (n1 << 4) | n0;
161
+ }
162
+ else
163
+ throw new Error('Invalid escape sequence [Line ' + lineNum + ']');
164
+ }
165
+ // normal character
166
+ if (value === null)
167
+ name += String.fromCharCode(char);
168
+ else
169
+ value += String.fromCharCode(char);
170
+ }
171
+ const n = name.trim();
172
+ if (value !== null) {
173
+ props[n] = value.trim();
174
+ }
175
+ else if (n.length > 0)
176
+ throw new Error('Invalid name/value pair [Line ' + lineNum + ']');
177
+ return props;
178
+ }
179
+ //# sourceMappingURL=fantomPropsToObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fantomPropsToObject.js","sourceRoot":"","sources":["../../src/fantomProps/fantomPropsToObject.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,KAAa;IACxD,IAAI,CAAC,GAAG,CAAC,CAAA;IAET,MAAM,QAAQ,GAAG,GAAW,EAAE;QAC7B,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE;YACrB,CAAC,EAAE,CAAA;YACH,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;SAC9B;;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I,CAAC,CAAC,GAAG,EAAE,CAAA;aAC9C;;gBACA,MAAM,IAAI,KAAK,CACd,gCAAgC,GAAG,OAAO,GAAG,GAAG,CAChD,CAAA;SACF;QAED,mBAAmB;QACnB,IAAI,KAAK,KAAK,IAAI;YAAE,IAAI,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;;YAChD,KAAK,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;KACvC;IAED,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IACrB,IAAI,KAAK,KAAK,IAAI,EAAE;QACnB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;KACvB;SAAM,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,OAAO,GAAG,GAAG,CAAC,CAAA;IAElE,OAAO,KAAK,CAAA;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Converts props file to json file.
3
+ */
4
+ export default function generateJsonFromFantomPropsFile(inputPath?: string, outputPath?: string): Promise<void>;
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
+ */
4
+ import * as fs from 'fs';
5
+ import readFantomPropsFile from './readFantomPropsFile';
6
+ /**
7
+ * Converts props file to json file.
8
+ */
9
+ export default async function generateJsonFromFantomPropsFile(inputPath = '../locale/en.props', outputPath = './src/localeKeys.json') {
10
+ const result = await readFantomPropsFile(inputPath);
11
+ fs.writeFileSync(outputPath, JSON.stringify(result, null, '\t'));
12
+ }
13
+ //# sourceMappingURL=generateJsonFromFantomPropsFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateJsonFromFantomPropsFile.js","sourceRoot":"","sources":["../../src/fantomProps/generateJsonFromFantomPropsFile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AAEvD;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,+BAA+B,CAC5D,SAAS,GAAG,oBAAoB,EAChC,UAAU,GAAG,uBAAuB;IAEpC,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAA;IAEnD,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACjE,CAAC"}
@@ -0,0 +1 @@
1
+ export default function localePropsToJson(inputPath?: string, outputPath?: string, includeOnlyPrefixedBy?: string): Promise<void>;
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
+ */
4
+ import * as fs from 'fs';
5
+ import readFantomPropsFile from './readFantomPropsFile';
6
+ export default async function localePropsToJson(inputPath = '../locale/en.props', outputPath = './src/localeKeys.json', includeOnlyPrefixedBy = '') {
7
+ const props = await readFantomPropsFile(inputPath);
8
+ let localeKeys;
9
+ if (includeOnlyPrefixedBy) {
10
+ localeKeys = Object.fromEntries(Object.keys(props)
11
+ .filter((key) => key.startsWith(includeOnlyPrefixedBy))
12
+ .map((key) => [
13
+ key.replace(includeOnlyPrefixedBy, '').replaceAll('.', '_'),
14
+ key,
15
+ ]));
16
+ }
17
+ else {
18
+ localeKeys = Object.fromEntries(Object.keys(props).map((key) => [key.replaceAll('.', '_'), key]));
19
+ }
20
+ fs.writeFileSync(outputPath, JSON.stringify(localeKeys, null, '\t'));
21
+ }
22
+ //# sourceMappingURL=localePropsToJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localePropsToJson.js","sourceRoot":"","sources":["../../src/fantomProps/localePropsToJson.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAC9C,SAAS,GAAG,oBAAoB,EAChC,UAAU,GAAG,uBAAuB,EACpC,qBAAqB,GAAG,EAAE;IAE1B,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAA;IAElD,IAAI,UAAU,CAAA;IACd,IAAI,qBAAqB,EAAE;QAC1B,UAAU,GAAG,MAAM,CAAC,WAAW,CAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAChB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;aACtD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YACb,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;YAC3D,GAAG;SACH,CAAC,CACH,CAAA;KACD;SAAM;QACN,UAAU,GAAG,MAAM,CAAC,WAAW,CAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAChE,CAAA;KACD;IAED,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACrE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Props } from './fantomPropsToObject';
2
+ /**
3
+ * Asynchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
4
+ */
5
+ export default function readFantomPropsFile(path: string): Promise<Props>;
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
+ */
4
+ import * as fs from 'fs';
5
+ import { parseFantomProps } from './fantomPropsToObject';
6
+ /**
7
+ * Asynchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
8
+ */
9
+ export default function readFantomPropsFile(path) {
10
+ return new Promise((resolve, reject) => {
11
+ const fileStream = fs.createReadStream(path);
12
+ fileStream.once('readable', function () {
13
+ const readChar = () => {
14
+ return fileStream.read(1)?.[0] ?? -1;
15
+ };
16
+ const unreadChar = (char) => {
17
+ return fileStream.unshift(new Uint8Array([char]));
18
+ };
19
+ try {
20
+ resolve(parseFantomProps(readChar, unreadChar));
21
+ }
22
+ catch (error) {
23
+ reject(error);
24
+ }
25
+ finally {
26
+ try {
27
+ fileStream.close();
28
+ }
29
+ catch (err) {
30
+ console.error(err);
31
+ }
32
+ }
33
+ });
34
+ });
35
+ }
36
+ //# sourceMappingURL=readFantomPropsFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readFantomPropsFile.js","sourceRoot":"","sources":["../../src/fantomProps/readFantomPropsFile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAAS,MAAM,uBAAuB,CAAA;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,IAAY;IACvD,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAE5C,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE;YAC3B,MAAM,QAAQ,GAAG,GAAW,EAAE;gBAC7B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;YACrC,CAAC,CAAA;YAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;gBACnC,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAClD,CAAC,CAAA;YAED,IAAI;gBACH,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAA;aAC/C;YAAC,OAAO,KAAK,EAAE;gBACf,MAAM,CAAC,KAAK,CAAC,CAAA;aACb;oBAAS;gBACT,IAAI;oBACH,UAAU,CAAC,KAAK,EAAE,CAAA;iBAClB;gBAAC,OAAO,GAAG,EAAE;oBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;iBAClB;aACD;QACF,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { AlarmFilter } from './openFin5Alarm';
2
+ import { HistorianArgs, HistorianType } from './openFin5Historian';
3
+ export declare const getFin5top: (notifyFailure?: () => void) => Fin5Top | null;
4
+ export declare const fin5Top: Fin5Top | null;
5
+ export declare function isWindowTopFin5(notifyFailure?: () => void): boolean;
6
+ export interface Fin5Top {
7
+ app: Fin5App;
8
+ languageManager: LanguageManager;
9
+ finstack?: {
10
+ projectName?: string;
11
+ device?: {
12
+ currentUser?: {
13
+ toObj: () => unknown;
14
+ };
15
+ };
16
+ };
17
+ }
18
+ export interface Fin5App {
19
+ /**
20
+ * Toggles FIN right side menu.
21
+ * The forceTo parameter can be used to enforce a specific status instead of a toggling behaviour,
22
+ * where: true -> menu closed, false -> menu open
23
+ */
24
+ ToggleCollapse: (forceTo: boolean) => void;
25
+ /**
26
+ * Returns current target record id.
27
+ */
28
+ TargetRef: () => TargetRef;
29
+ /**
30
+ * Updates the current target record id.
31
+ * Navigates the current app to the specified
32
+ * <code>targetRef</code>. Target Ref is the id of any equip/site etc..
33
+ */
34
+ NavigateToTargetRef: (targetRef: TargetRef, maintainView: boolean) => void;
35
+ /**
36
+ * Navigates to a particular application (trends, notes .. etc) under a specific target.
37
+ * @param {Fin5AppNames} appName name of the application
38
+ * @param {TargetRef} targetRef id of the target. Is the id of the equip/site.. etc to where the app should navigate
39
+ * @param {boolean} skipRef is the flag indicating where to ignore the target ref if not mentioned. If this flag is true and the target ref is not provided, then the navigation will be made to the root target ref and will not be obtained from where the app already is
40
+ */
41
+ NavigateToApp: (appName: Fin5AppNames, targetRef?: TargetRef, skipRef?: boolean, params?: string[]) => Promise<void>;
42
+ /**
43
+ * Method to open a url on the application LHS. The LHS here is the <code>iframe</code> where all
44
+ * the graphics etc are opened.
45
+ *
46
+ * @method LoadApplication
47
+ * @param {string} url - Is the url which is to be loaded
48
+ * @param {string} title - Specifies the title to be displayed on the iframe object
49
+ * @param {string} targetId - Specifies the id of the equip (etc) to which the main navigation update.
50
+ * @param {object} settings - extra settings that can be passed in when calling hte func
51
+ * @param {boolean} settings.collapse - flag indicating the collapse state of the RHS app panel
52
+ */
53
+ LoadApplication: (url: string, title?: string, targetRef?: TargetRef, settings?: {
54
+ collapse?: boolean;
55
+ }) => Promise<void>;
56
+ /**
57
+ * Get the filters object from the alarms application.
58
+ */
59
+ GetAlarmFilters: () => AlarmFilter;
60
+ /**
61
+ * Sets the filter settings for the alarms.
62
+ * @param {AlarmFilter} filters Is the object that defines the filter properties.
63
+ * @param {boolean} historical Flag indicating if the filter properties need to be applied to the historical alarms.
64
+ */
65
+ SetAlarmFilters: (filters: AlarmFilter, historical?: boolean) => void;
66
+ /**
67
+ * Navigates to the historian app and loads the graphs as per the passed arguments. The graph will be drawn for the passed "point" ids or for a "query" id or for a "string" query
68
+ * @param {HistorianType} type is the type of graph arg. Available args are:
69
+ * - point : the args will have point ids in an array
70
+ * - query : the arg will be the id of a saved chart query
71
+ * - string : the arg will be a query string
72
+ * @param {HistorianArgs} args is the array/string for point ids, the query id or the raw query string
73
+ */
74
+ OpenHistorianWithOptions: (type: HistorianType, args: HistorianArgs) => void;
75
+ findComponent: (name: string) => Fin5AppComponent;
76
+ /**
77
+ * @see https://ractive.js.org/api/#ractiveobserve
78
+ */
79
+ observe: (keypath: string, callback: (newValue: unknown, oldValue: unknown, keypath: string) => void) => {
80
+ cancel: () => void;
81
+ };
82
+ set: (name: string, value: unknown) => Promise<undefined>;
83
+ get: (name: string) => Promise<unknown>;
84
+ APP_NAMES: typeof Fin5AppNames;
85
+ }
86
+ export declare enum Fin5AppNames {
87
+ EQUIP = "equip",
88
+ GRAPHICS = "graphics",
89
+ POINTS = "points",
90
+ ALARMS = "alarms",
91
+ NOTES = "notes",
92
+ SUMMARY = "summary",
93
+ SUMMARY_TOPICS = "summaryList",
94
+ TOOLS = "tools",
95
+ SCHEDULES = "schedules",
96
+ SCHEDULE_LIST = "scheduleList",
97
+ HISTORIAN = "trends",
98
+ TREND_LIST = "trendList",
99
+ SEARCH = "search",
100
+ LOGOUT = "logout",
101
+ GENERIC = "generic",
102
+ REPORTS = "reports"
103
+ }
104
+ interface LanguageManager {
105
+ currentLang: string;
106
+ }
107
+ interface Fin5AppComponent {
108
+ set: (value: unknown) => Promise<undefined>;
109
+ }
110
+ export declare type TargetRef = string | null | undefined;
111
+ export {};
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
+ */
4
+ class Fin5TopRetriever {
5
+ static _fin5Top;
6
+ static get fin5Top() {
7
+ return this.getFin5top();
8
+ }
9
+ static getFin5top = (notifyFailure) => {
10
+ if (this._fin5Top === undefined) {
11
+ this._fin5Top = isWindowTopFin5(notifyFailure)
12
+ ? window.top // Cast to unknown to obscure properties from Window to simplify usage.
13
+ : null;
14
+ }
15
+ return this._fin5Top;
16
+ };
17
+ }
18
+ export const getFin5top = Fin5TopRetriever.getFin5top;
19
+ export const fin5Top = Fin5TopRetriever.fin5Top;
20
+ export function isWindowTopFin5(notifyFailure) {
21
+ try {
22
+ window?.top?.origin;
23
+ if (window.top.finstack) {
24
+ return true;
25
+ }
26
+ else {
27
+ throw new Error('FIN 5 top not available');
28
+ }
29
+ }
30
+ catch (err) {
31
+ console.warn(err);
32
+ notifyFailure?.();
33
+ return false;
34
+ }
35
+ }
36
+ export var Fin5AppNames;
37
+ (function (Fin5AppNames) {
38
+ Fin5AppNames["EQUIP"] = "equip";
39
+ Fin5AppNames["GRAPHICS"] = "graphics";
40
+ Fin5AppNames["POINTS"] = "points";
41
+ Fin5AppNames["ALARMS"] = "alarms";
42
+ Fin5AppNames["NOTES"] = "notes";
43
+ Fin5AppNames["SUMMARY"] = "summary";
44
+ Fin5AppNames["SUMMARY_TOPICS"] = "summaryList";
45
+ Fin5AppNames["TOOLS"] = "tools";
46
+ Fin5AppNames["SCHEDULES"] = "schedules";
47
+ Fin5AppNames["SCHEDULE_LIST"] = "scheduleList";
48
+ Fin5AppNames["HISTORIAN"] = "trends";
49
+ Fin5AppNames["TREND_LIST"] = "trendList";
50
+ Fin5AppNames["SEARCH"] = "search";
51
+ Fin5AppNames["LOGOUT"] = "logout";
52
+ Fin5AppNames["GENERIC"] = "generic";
53
+ Fin5AppNames["REPORTS"] = "reports";
54
+ })(Fin5AppNames || (Fin5AppNames = {}));
55
+ //# sourceMappingURL=fin5Top.js.map