@lysaab/lysa-pep 6.1.1 → 7.0.0

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 (85) hide show
  1. package/README.md +7 -0
  2. package/lib/README.md +51 -0
  3. package/lib/package.json +73 -0
  4. package/{pages → lib/pages}/IsPep/IsPepPage.js +2 -3
  5. package/{pages → lib/pages}/PepContext.d.ts +3 -3
  6. package/{pages → lib/pages}/RelationPage/RelationPage.js +2 -3
  7. package/{pages → lib/pages}/RolePage/RolePage.js +2 -3
  8. package/{pages → lib/pages}/StatusPage/StatusPage.js +2 -3
  9. package/package.json +20 -21
  10. package/public/favicon.ico +0 -0
  11. package/public/index.html +43 -0
  12. package/public/logo192.png +0 -0
  13. package/public/logo512.png +0 -0
  14. package/public/manifest.json +25 -0
  15. package/public/robots.txt +2 -0
  16. package/src/App.scss +5 -0
  17. package/src/App.test.tsx +9 -0
  18. package/src/App.tsx +17 -0
  19. package/src/Exports.ts +12 -0
  20. package/src/components/PepAnswers.scss +7 -0
  21. package/src/components/PepAnswers.tsx +218 -0
  22. package/src/demo/Done.tsx +21 -0
  23. package/src/demo/Localization.tsx +66 -0
  24. package/src/demo/LocalizationContext.tsx +61 -0
  25. package/src/demo/Pep.tsx +172 -0
  26. package/src/index.css +13 -0
  27. package/src/index.tsx +13 -0
  28. package/src/locales/da.json +98 -0
  29. package/src/locales/de.json +98 -0
  30. package/src/locales/defaultMessages.json +335 -0
  31. package/src/locales/en.json +98 -0
  32. package/src/locales/fi.json +98 -0
  33. package/src/locales/sv.json +98 -0
  34. package/src/locales/whitelist_da.json +2 -0
  35. package/src/locales/whitelist_en.json +2 -0
  36. package/src/locales/whitelist_fi.json +2 -0
  37. package/src/locales/whitelist_sv.json +2 -0
  38. package/src/logo.svg +1 -0
  39. package/src/model/PepModel.ts +54 -0
  40. package/src/pages/IsPep/IsPepMessages.ts +11 -0
  41. package/src/pages/IsPep/IsPepPage.tsx +119 -0
  42. package/src/pages/PepContext.tsx +150 -0
  43. package/src/pages/RelationPage/RelationMessages.ts +74 -0
  44. package/src/pages/RelationPage/RelationPage.tsx +306 -0
  45. package/src/pages/RolePage/RoleMessages.ts +128 -0
  46. package/src/pages/RolePage/RolePage.tsx +359 -0
  47. package/src/pages/StatusPage/StatusMessages.ts +59 -0
  48. package/src/pages/StatusPage/StatusPage.tsx +237 -0
  49. package/src/react-app-env.d.ts +1 -0
  50. package/src/serviceWorker.ts +143 -0
  51. package/src/utils/Possession.ts +41 -0
  52. package/translationRunner.js +7 -0
  53. package/tsconfig.json +26 -0
  54. package/tsconfig_build.json +19 -0
  55. /package/{Exports.d.ts → lib/Exports.d.ts} +0 -0
  56. /package/{Exports.js → lib/Exports.js} +0 -0
  57. /package/{components → lib/components}/PepAnswers.d.ts +0 -0
  58. /package/{components → lib/components}/PepAnswers.js +0 -0
  59. /package/{components → lib/components}/PepAnswers.scss +0 -0
  60. /package/{messages → lib/messages}/src/components/PepAnswers.json +0 -0
  61. /package/{messages → lib/messages}/src/pages/IsPep/IsPepMessages.json +0 -0
  62. /package/{messages → lib/messages}/src/pages/IsPep/IsPepPage.json +0 -0
  63. /package/{messages → lib/messages}/src/pages/RelationPage/RelationMessages.json +0 -0
  64. /package/{messages → lib/messages}/src/pages/RelationPage/RelationPage.json +0 -0
  65. /package/{messages → lib/messages}/src/pages/RolePage/RoleMessages.json +0 -0
  66. /package/{messages → lib/messages}/src/pages/RolePage/RolePage.json +0 -0
  67. /package/{messages → lib/messages}/src/pages/StatusPage/StatusMessages.json +0 -0
  68. /package/{messages → lib/messages}/src/pages/StatusPage/StatusPage.json +0 -0
  69. /package/{model → lib/model}/PepModel.d.ts +0 -0
  70. /package/{model → lib/model}/PepModel.js +0 -0
  71. /package/{pages → lib/pages}/IsPep/IsPepMessages.d.ts +0 -0
  72. /package/{pages → lib/pages}/IsPep/IsPepMessages.js +0 -0
  73. /package/{pages → lib/pages}/IsPep/IsPepPage.d.ts +0 -0
  74. /package/{pages → lib/pages}/PepContext.js +0 -0
  75. /package/{pages → lib/pages}/RelationPage/RelationMessages.d.ts +0 -0
  76. /package/{pages → lib/pages}/RelationPage/RelationMessages.js +0 -0
  77. /package/{pages → lib/pages}/RelationPage/RelationPage.d.ts +0 -0
  78. /package/{pages → lib/pages}/RolePage/RoleMessages.d.ts +0 -0
  79. /package/{pages → lib/pages}/RolePage/RoleMessages.js +0 -0
  80. /package/{pages → lib/pages}/RolePage/RolePage.d.ts +0 -0
  81. /package/{pages → lib/pages}/StatusPage/StatusMessages.d.ts +0 -0
  82. /package/{pages → lib/pages}/StatusPage/StatusMessages.js +0 -0
  83. /package/{pages → lib/pages}/StatusPage/StatusPage.d.ts +0 -0
  84. /package/{utils → lib/utils}/Possession.d.ts +0 -0
  85. /package/{utils → lib/utils}/Possession.js +0 -0
@@ -0,0 +1,143 @@
1
+ // This optional code is used to register a service worker.
2
+ // register() is not called by default.
3
+
4
+ // This lets the app load faster on subsequent visits in production, and gives
5
+ // it offline capabilities. However, it also means that developers (and users)
6
+ // will only see deployed updates on subsequent visits to a page, after all the
7
+ // existing tabs open on the page have been closed, since previously cached
8
+ // resources are updated in the background.
9
+
10
+ // To learn more about the benefits of this model and instructions on how to
11
+ // opt-in, read https://bit.ly/CRA-PWA
12
+
13
+ const isLocalhost = Boolean(
14
+ window.location.hostname === 'localhost' ||
15
+ // [::1] is the IPv6 localhost address.
16
+ window.location.hostname === '[::1]' ||
17
+ // 127.0.0.1/8 is considered localhost for IPv4.
18
+ window.location.hostname.match(
19
+ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20
+ )
21
+ );
22
+
23
+ type Config = {
24
+ onSuccess?: (registration: ServiceWorkerRegistration) => void;
25
+ onUpdate?: (registration: ServiceWorkerRegistration) => void;
26
+ };
27
+
28
+ export function register(config?: Config) {
29
+ if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
30
+ // The URL constructor is available in all browsers that support SW.
31
+ const publicUrl = new URL(
32
+ (process as { env: { [key: string]: string } }).env.PUBLIC_URL,
33
+ window.location.href
34
+ );
35
+ if (publicUrl.origin !== window.location.origin) {
36
+ // Our service worker won't work if PUBLIC_URL is on a different origin
37
+ // from what our page is served on. This might happen if a CDN is used to
38
+ // serve assets; see https://github.com/facebook/create-react-app/issues/2374
39
+ return;
40
+ }
41
+
42
+ window.addEventListener('load', () => {
43
+ const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
44
+
45
+ if (isLocalhost) {
46
+ // This is running on localhost. Let's check if a service worker still exists or not.
47
+ checkValidServiceWorker(swUrl, config);
48
+
49
+ // Add some additional logging to localhost, pointing developers to the
50
+ // service worker/PWA documentation.
51
+ navigator.serviceWorker.ready.then(() => {
52
+ console.log(
53
+ 'This web app is being served cache-first by a service ' +
54
+ 'worker. To learn more, visit https://bit.ly/CRA-PWA'
55
+ );
56
+ });
57
+ } else {
58
+ // Is not localhost. Just register service worker
59
+ registerValidSW(swUrl, config);
60
+ }
61
+ });
62
+ }
63
+ }
64
+
65
+ function registerValidSW(swUrl: string, config?: Config) {
66
+ navigator.serviceWorker
67
+ .register(swUrl)
68
+ .then(registration => {
69
+ registration.onupdatefound = () => {
70
+ const installingWorker = registration.installing;
71
+ if (installingWorker == null) {
72
+ return;
73
+ }
74
+ installingWorker.onstatechange = () => {
75
+ if (installingWorker.state === 'installed') {
76
+ if (navigator.serviceWorker.controller) {
77
+ // At this point, the updated precached content has been fetched,
78
+ // but the previous service worker will still serve the older
79
+ // content until all client tabs are closed.
80
+ console.log(
81
+ 'New content is available and will be used when all ' +
82
+ 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
83
+ );
84
+
85
+ // Execute callback
86
+ if (config && config.onUpdate) {
87
+ config.onUpdate(registration);
88
+ }
89
+ } else {
90
+ // At this point, everything has been precached.
91
+ // It's the perfect time to display a
92
+ // "Content is cached for offline use." message.
93
+ console.log('Content is cached for offline use.');
94
+
95
+ // Execute callback
96
+ if (config && config.onSuccess) {
97
+ config.onSuccess(registration);
98
+ }
99
+ }
100
+ }
101
+ };
102
+ };
103
+ })
104
+ .catch(error => {
105
+ console.error('Error during service worker registration:', error);
106
+ });
107
+ }
108
+
109
+ function checkValidServiceWorker(swUrl: string, config?: Config) {
110
+ // Check if the service worker can be found. If it can't reload the page.
111
+ fetch(swUrl)
112
+ .then(response => {
113
+ // Ensure service worker exists, and that we really are getting a JS file.
114
+ const contentType = response.headers.get('content-type');
115
+ if (
116
+ response.status === 404 ||
117
+ (contentType != null && contentType.indexOf('javascript') === -1)
118
+ ) {
119
+ // No service worker found. Probably a different app. Reload the page.
120
+ navigator.serviceWorker.ready.then(registration => {
121
+ registration.unregister().then(() => {
122
+ window.location.reload();
123
+ });
124
+ });
125
+ } else {
126
+ // Service worker found. Proceed as normal.
127
+ registerValidSW(swUrl, config);
128
+ }
129
+ })
130
+ .catch(() => {
131
+ console.log(
132
+ 'No internet connection found. App is running in offline mode.'
133
+ );
134
+ });
135
+ }
136
+
137
+ export function unregister() {
138
+ if ('serviceWorker' in navigator) {
139
+ navigator.serviceWorker.ready.then(registration => {
140
+ registration.unregister();
141
+ });
142
+ }
143
+ }
@@ -0,0 +1,41 @@
1
+ export function formatPossessive(text: string | undefined, locale: string) {
2
+ if (!text) {
3
+ return;
4
+ }
5
+
6
+ const language = locale.substr(0, 2);
7
+
8
+ if (language === "sv") {
9
+ return formatSwedish(text);
10
+ } else if (language === "en") {
11
+ return formatEnglish(text);
12
+ }
13
+
14
+ return text;
15
+ }
16
+
17
+ function formatSwedish(text: string) {
18
+ if (
19
+ text[text.length - 1] !== "s" &&
20
+ text[text.length - 1] !== "z" &&
21
+ text[text.length - 1] !== "x"
22
+ ) {
23
+ text += "s";
24
+ }
25
+ return text;
26
+ }
27
+
28
+ // There are no proper rules for English
29
+ // Jess -> Jess's
30
+ // Charles -> Charles's or Charles'
31
+ // Jesus -> Jesus'
32
+ // Martinez -> Martinez's or Martinez'
33
+ // Alex -> Alex's
34
+ // Hendrix -> Hendrix'
35
+ function formatEnglish(text: string) {
36
+ if (text[text.length - 1] === "s") {
37
+ return text + "'";
38
+ }
39
+
40
+ return text + "'s";
41
+ }
@@ -0,0 +1,7 @@
1
+ const manageTranslations = require("react-intl-translations-manager").default;
2
+ manageTranslations({
3
+ messagesDirectory: "build/messages",
4
+ translationsDirectory: "src/locales",
5
+ languages: ["en", "sv", "da", "fi"],
6
+ singleMessagesFile: true,
7
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "lib": [
5
+ "dom",
6
+ "dom.iterable",
7
+ "esnext"
8
+ ],
9
+ "allowJs": true,
10
+ "skipLibCheck": true,
11
+ "esModuleInterop": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "strict": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "module": "esnext",
16
+ "moduleResolution": "node",
17
+ "resolveJsonModule": true,
18
+ "isolatedModules": true,
19
+ "noEmit": true,
20
+ "jsx": "react-jsx",
21
+ "noFallthroughCasesInSwitch": true
22
+ },
23
+ "include": [
24
+ "src"
25
+ ]
26
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["dom", "dom.iterable", "esnext"],
4
+ "skipLibCheck": true,
5
+ "esModuleInterop": true,
6
+ "target": "ES2015",
7
+ "module": "esnext",
8
+ "declaration": true,
9
+ "outDir": "lib",
10
+ "strict": true,
11
+ "removeComments": true,
12
+ "jsx": "react",
13
+ "allowSyntheticDefaultImports": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "moduleResolution": "node",
16
+ "resolveJsonModule": true
17
+ },
18
+ "include": ["src/Exports.ts"]
19
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes