@mideind/netskrafl-react 1.0.0-beta.5 → 1.0.0-beta.7

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 (67) hide show
  1. package/{src/css/skrafl-explo.css → dist/cjs/css/netskrafl.css} +1068 -174
  2. package/dist/cjs/index.js +32477 -364
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/{cjs/index.css → esm/css/netskrafl.css} +1043 -350
  5. package/dist/esm/index.js +32475 -364
  6. package/dist/esm/index.js.map +1 -1
  7. package/dist/types.d.ts +2 -1
  8. package/package.json +14 -2
  9. package/.eslintignore +0 -8
  10. package/.eslintrc.json +0 -13
  11. package/dist/esm/index.css +0 -6837
  12. package/rollup.config.js +0 -60
  13. package/src/components/index.ts +0 -2
  14. package/src/components/netskrafl/Netskrafl.stories.tsx +0 -66
  15. package/src/components/netskrafl/Netskrafl.tsx +0 -138
  16. package/src/components/netskrafl/Netskrafl.types.ts +0 -7
  17. package/src/components/netskrafl/index.ts +0 -2
  18. package/src/css/fonts.css +0 -4
  19. package/src/css/glyphs.css +0 -224
  20. package/src/fonts/glyphicons-regular.eot +0 -0
  21. package/src/fonts/glyphicons-regular.ttf +0 -0
  22. package/src/fonts/glyphicons-regular.woff +0 -0
  23. package/src/index.ts +0 -2
  24. package/src/messages/messages.json +0 -1576
  25. package/src/mithril/actions.ts +0 -319
  26. package/src/mithril/bag.ts +0 -65
  27. package/src/mithril/bestdisplay.ts +0 -74
  28. package/src/mithril/blankdialog.ts +0 -94
  29. package/src/mithril/board.ts +0 -339
  30. package/src/mithril/buttons.ts +0 -303
  31. package/src/mithril/challengedialog.ts +0 -186
  32. package/src/mithril/channel.ts +0 -162
  33. package/src/mithril/chat.ts +0 -228
  34. package/src/mithril/components.ts +0 -496
  35. package/src/mithril/dragdrop.ts +0 -219
  36. package/src/mithril/elopage.ts +0 -202
  37. package/src/mithril/friend.ts +0 -227
  38. package/src/mithril/game.ts +0 -1378
  39. package/src/mithril/gameview.ts +0 -111
  40. package/src/mithril/globalstate.ts +0 -33
  41. package/src/mithril/i18n.ts +0 -186
  42. package/src/mithril/localstorage.ts +0 -133
  43. package/src/mithril/login.ts +0 -122
  44. package/src/mithril/logo.ts +0 -323
  45. package/src/mithril/main.ts +0 -755
  46. package/src/mithril/mithril.ts +0 -29
  47. package/src/mithril/model.ts +0 -855
  48. package/src/mithril/movelistitem.ts +0 -226
  49. package/src/mithril/page.ts +0 -856
  50. package/src/mithril/playername.ts +0 -91
  51. package/src/mithril/promodialog.ts +0 -82
  52. package/src/mithril/recentlist.ts +0 -148
  53. package/src/mithril/request.ts +0 -52
  54. package/src/mithril/review.ts +0 -634
  55. package/src/mithril/rightcolumn.ts +0 -398
  56. package/src/mithril/searchbutton.ts +0 -118
  57. package/src/mithril/statsdisplay.ts +0 -109
  58. package/src/mithril/tabs.ts +0 -169
  59. package/src/mithril/tile.ts +0 -145
  60. package/src/mithril/twoletter.ts +0 -76
  61. package/src/mithril/types.ts +0 -384
  62. package/src/mithril/userinfodialog.ts +0 -171
  63. package/src/mithril/util.ts +0 -304
  64. package/src/mithril/wait.ts +0 -246
  65. package/src/mithril/wordcheck.ts +0 -102
  66. package/tsconfig.json +0 -28
  67. package/vite.config.ts +0 -12
package/rollup.config.js DELETED
@@ -1,60 +0,0 @@
1
- // rollup.config.js
2
-
3
- import resolve from "@rollup/plugin-node-resolve";
4
- import alias from '@rollup/plugin-alias';
5
- import commonjs from "@rollup/plugin-commonjs";
6
- import typescript from "@rollup/plugin-typescript";
7
- import dts from "rollup-plugin-dts";
8
- import terser from "@rollup/plugin-terser";
9
- import peerDepsExternal from "rollup-plugin-peer-deps-external";
10
- import postcss from "rollup-plugin-postcss";
11
- import path from "path";
12
-
13
- const packageJson = require("./package.json");
14
-
15
- export default [
16
- {
17
- input: "src/index.ts",
18
- output: [
19
- // CommonJS module
20
- {
21
- file: packageJson.main,
22
- format: "cjs",
23
- sourcemap: true,
24
- },
25
- // ECMAScript module
26
- {
27
- file: packageJson.module,
28
- format: "esm",
29
- sourcemap: true,
30
- },
31
- ],
32
- plugins: [
33
- peerDepsExternal(),
34
- postcss({
35
- extensions: [".css"],
36
- modules: false,
37
- // extract: "index.css",
38
- }),
39
- alias({
40
- entries: [
41
- { find: '@', replacement: path.resolve(__dirname, 'src') }
42
- ]
43
- }),
44
- resolve({
45
- extensions: ['.js', '.jsx', '.ts', '.tsx']
46
- }),
47
- commonjs(),
48
- typescript({ tsconfig: "./tsconfig.json" }),
49
- terser(),
50
- ],
51
- external: ["react", "react-dom"],
52
- },
53
- {
54
- // Type declaration file (.d.ts)
55
- input: "src/index.ts",
56
- output: [{ file: "dist/types.d.ts", format: "es" }],
57
- external: [/\.css$/], // ignore .css file
58
- plugins: [dts.default()],
59
- },
60
- ];
@@ -1,2 +0,0 @@
1
-
2
- export * from "./netskrafl";
@@ -1,66 +0,0 @@
1
- // Netskrafl.stories.tsx
2
- import { StoryFn, Meta } from "@storybook/react";
3
- import { Netskrafl } from "./Netskrafl";
4
- import { INetskraflProps } from "./Netskrafl.types";
5
-
6
- export default {
7
- title: "ReactComponentLibrary/Netskrafl",
8
- component: Netskrafl,
9
- } as Meta<typeof Netskrafl>;
10
-
11
- const Template: StoryFn<typeof Netskrafl> = (args) => <Netskrafl {...args} />;
12
-
13
- // @ts-ignore
14
- const env = import.meta.env;
15
-
16
- // The following environment variables are typically stored in .env.local
17
- // in the project root directory
18
- const firebaseAPIKey = env.STORYBOOK_FIREBASE_API_KEY || "";
19
- const firebaseAppId = env.STORYBOOK_FIREBASE_APP_ID || "";
20
- const firebaseSenderId = env.STORYBOOK_FIREBASE_SENDER_ID || "";
21
- const measurementId = env.STORYBOOK_MEASUREMENT_ID || "";
22
- const movesAccessKey = env.STORYBOOK_MOVES_ACCESS_KEY || "";
23
-
24
- const args: INetskraflProps = {
25
- // The following settings are for testing purposes only
26
- state: {
27
- projectId: "netskrafl",
28
- firebaseAPIKey,
29
- databaseURL: "https://netskrafl.firebaseio.com",
30
- firebaseSenderId,
31
- firebaseAppId,
32
- measurementId,
33
- userEmail: "embla.mideind@gmail.com",
34
- userId: "",
35
- userNick: "VilliTest",
36
- userFullname: "Villi Thorsteinsson",
37
- serverUrl: "http://127.0.0.1:3001",
38
- movesUrl: "https://moves-dot-explo-dev.appspot.com",
39
- movesAccessKey,
40
- loginUrl: "",
41
- loginMethod: "malstadur",
42
- plan: "",
43
- hasPaid: false,
44
- runningLocal: true,
45
- }
46
- };
47
-
48
- // Paid user (subscriber)
49
- export const NetskraflPaidTest = Template.bind({});
50
- NetskraflPaidTest.args = { ...args, state: { ...args.state, plan: "friend", hasPaid: true } };
51
-
52
- // Free user (non-subscriber)
53
- export const NetskraflFreeTest = Template.bind({});
54
- NetskraflFreeTest.args = { ...args };
55
-
56
- // Explo Dev server
57
- export const ExploDev = Template.bind({});
58
- ExploDev.args = {
59
- ...args,
60
- state: {
61
- ...args.state,
62
- plan: "friend",
63
- hasPaid: true,
64
- serverUrl: "https://explo-dev.appspot.com",
65
- }
66
- };
@@ -1,138 +0,0 @@
1
- import React, { useEffect } from "react";
2
-
3
- import { INetskraflProps } from "./Netskrafl.types";
4
- import { GlobalState } from "@/mithril/globalstate";
5
- import { main } from "@/mithril/page";
6
-
7
- export { type INetskraflProps };
8
-
9
- import "@/css/fonts.css";
10
- import "@/css/glyphs.css";
11
- import "@/css/skrafl-explo.css";
12
-
13
- const DEFAULT_STATE: GlobalState = {
14
- projectId: "netskrafl",
15
- firebaseAPIKey: "",
16
- databaseURL: "",
17
- firebaseSenderId: "",
18
- firebaseAppId: "",
19
- measurementId: "",
20
- userEmail: "",
21
- userId: "",
22
- userNick: "",
23
- userFullname: "",
24
- locale: "is_IS",
25
- isExplo: false,
26
- serverUrl: "",
27
- movesUrl: "",
28
- movesAccessKey: "",
29
- token: "",
30
- loginUrl: "",
31
- loginMethod: "",
32
- newUser: false,
33
- beginner: false,
34
- fairPlay: true,
35
- plan: "", // Not a friend
36
- hasPaid: false,
37
- ready: false,
38
- readyTimed: false,
39
- uiFullscreen: true,
40
- uiLandscape: false,
41
- runningLocal: false,
42
- };
43
-
44
- const mountForUser = async (state: GlobalState, tokenExpired?: () => void): Promise<HTMLDivElement> => {
45
- // Return a DOM tree containing a mounted Netskrafl UI
46
- // for the user specified in the state object
47
- const { userEmail } = state;
48
- if (!userEmail) {
49
- // console.error("No user specified for Netskrafl UI");
50
- throw new Error("No user specified for Netskrafl UI");
51
- }
52
- // Check whether we already have a mounted UI for this user
53
- const elemId = `netskrafl-user-${userEmail}`;
54
- const existing = document.getElementById(elemId);
55
- if (existing) {
56
- // console.log("Netskrafl UI already mounted for user", userEmail);
57
- return existing as HTMLDivElement;
58
- }
59
- // Create a new div element to hold the UI
60
- const root = document.createElement('div');
61
- root.id = elemId;
62
- root.className = "netskrafl-loading";
63
- // Attach the partially-mounted div to the document body
64
- // as a placeholder while the UI is being mounted
65
- document.body.appendChild(root);
66
- const loginResult = await main(state, root);
67
- if (loginResult === "success") {
68
- // The UI was successfully mounted
69
- root.className = "netskrafl-user";
70
- return root;
71
- } else if (loginResult === "expired") {
72
- // We need a new token from the Málstaður backend
73
- root.className = "netskrafl-expired";
74
- tokenExpired && tokenExpired(); // This causes a reload of the component
75
- return root;
76
- }
77
- // console.error("Failed to mount Netskrafl UI for user", userEmail);
78
- throw new Error("Failed to mount Netskrafl UI");
79
- }
80
-
81
- const NetskraflImpl: React.FC<INetskraflProps> = ({ state, tokenExpired }) => {
82
- const ref = React.createRef<HTMLDivElement>();
83
- const completeState = { ...DEFAULT_STATE, ...state };
84
- const { userEmail } = completeState;
85
-
86
- useEffect(() => {
87
- // Load the Netskrafl (Mithril) UI for a new user
88
- // console.log("Mounting Netskrafl UI for user", userEmail);
89
- if (!userEmail) return;
90
- const container = ref.current;
91
- if (!container) {
92
- console.error("No container for Netskrafl UI");
93
- return;
94
- }
95
- const elemId = `netskrafl-user-${userEmail}`;
96
- if (container.firstElementChild?.id === elemId) {
97
- // Already exists and correctly mounted
98
- // console.log("Netskrafl UI already mounted with elemId", elemId);
99
- return;
100
- }
101
- try {
102
- mountForUser(completeState, tokenExpired).then((div) => {
103
- // Attach the div as a child of the container
104
- // instead of any previous children
105
- const container = ref.current;
106
- if (container) {
107
- container.innerHTML = "";
108
- container.appendChild(div);
109
- }
110
- });
111
- } catch (err) {
112
- console.error("Failed to mount Netskrafl UI for user", userEmail);
113
- const container = document.getElementById("netskrafl-container");
114
- if (container)
115
- container.innerHTML = "";
116
- }
117
- return () => {
118
- // console.log("Dismounting Netskrafl UI for user", userEmail);
119
- // Move the Netskrafl UI to a hidden div under the body element
120
- // when the component is unmounted
121
- const container = document.getElementById("netskrafl-container");
122
- const div = container?.firstElementChild;
123
- if (div?.id === elemId) {
124
- document.body.appendChild(div);
125
- }
126
- };
127
- }, [userEmail]);
128
-
129
- return (
130
- <div className="netskrafl">
131
- <div className="netskrafl-container" id="netskrafl-container" ref={ref}>
132
- { /* The Netskrafl single-page UI will be rendered here */ }
133
- </div>
134
- </div>
135
- );
136
- };
137
-
138
- export const Netskrafl = React.memo(NetskraflImpl);
@@ -1,7 +0,0 @@
1
-
2
- import { GlobalState } from "../../mithril/globalstate";
3
-
4
- export interface INetskraflProps {
5
- state: Partial<GlobalState>;
6
- tokenExpired?: () => void;
7
- }
@@ -1,2 +0,0 @@
1
-
2
- export * from "./Netskrafl";
package/src/css/fonts.css DELETED
@@ -1,4 +0,0 @@
1
-
2
- @import url('https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,400;0,700;1,400;1,700&display=swap');
3
- @import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400;1,700&display=swap');
4
- @import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap');
@@ -1,224 +0,0 @@
1
- /*
2
-
3
- Glyphs.css
4
-
5
- Style support for Glyphicons
6
-
7
- Copyright © 2024 Miðeind ehf.
8
- Author: Vilhjalmur Thorsteinsson
9
-
10
- The Creative Commons Attribution-NonCommercial 4.0
11
- International Public License (CC-BY-NC 4.0) applies to this software.
12
- For further information, see https://github.com/mideind/Netskrafl
13
-
14
- */
15
-
16
- @font-face {
17
- font-family: 'Glyphicons Regular';
18
- /* The following source URLs are patched up at run-time
19
- to point to the backend server */
20
- src: url('../static/glyphicons-regular.eot') format('embedded-opentype'),
21
- url('../static/glyphicons-regular.woff') format('woff'),
22
- url('../static/glyphicons-regular.ttf') format('truetype');
23
- }
24
-
25
- .glyphicon {
26
- position: relative;
27
- top: 2px;
28
- display: inline-block;
29
- font-family: 'Glyphicons Regular';
30
- font-style: normal;
31
- font-weight: normal;
32
- line-height: 1;
33
- }
34
-
35
- .glyphicon-play:before {
36
- content: "\E174";
37
- }
38
- .glyphicon-exclamation-sign:before {
39
- content: "\E197";
40
- }
41
- .glyphicon-log-in:before {
42
- content: "\E387";
43
- }
44
- .glyphicon-log-out:before {
45
- content: "\E388";
46
- }
47
- .glyphicon-screenshot:before {
48
- content: "\E186";
49
- }
50
- .glyphicon-refresh:before {
51
- content: "\E082";
52
- }
53
- .glyphicon-forward:before {
54
- content: "\E177";
55
- }
56
- .glyphicon-fire:before {
57
- content: "\E023";
58
- }
59
- .glyphicon-ok:before {
60
- content: "\E207";
61
- }
62
- .glyphicon-remove:before {
63
- content: "\E208";
64
- }
65
- .glyphicon-info-sign:before {
66
- content: "\E196";
67
- }
68
- .glyphicon-cog:before {
69
- content: "\E137";
70
- }
71
- .glyphicon-chevron-left:before {
72
- content: "\E225";
73
- }
74
- .glyphicon-chevron-right:before {
75
- content: "\E224";
76
- }
77
- .glyphicon-circle-arrow-down:before {
78
- content: "\E220";
79
- }
80
- .glyphicon-download:before {
81
- content: "\E201";
82
- }
83
- .glyphicon-star:before {
84
- content: "\E050";
85
- }
86
- .glyphicon-flag:before {
87
- content: "\E267";
88
- }
89
- .glyphicon-flag-after:after {
90
- content: "\E267";
91
- }
92
- .glyphicon-bookmark:before {
93
- content: "\E073";
94
- }
95
- .glyphicon-star-empty:before {
96
- content: "\E049";
97
- }
98
- .glyphicon-hand-right:before {
99
- content: "\E346";
100
- }
101
- .glyphicon-hand-left:before {
102
- content: "\E347";
103
- }
104
- .glyphicon-thumbs-up:before {
105
- content: "\E344";
106
- }
107
- .glyphicon-thumbs-down:before {
108
- content: "\E345";
109
- }
110
- .glyphicon-remove-circle:before {
111
- content: "\E198";
112
- }
113
- .glyphicon-th:before {
114
- content: "\E157";
115
- }
116
- .glyphicon-user:before {
117
- content: "\E004";
118
- }
119
- .glyphicon-comment:before {
120
- content: "\E310";
121
- }
122
- .glyphicon-eye-open:before {
123
- content: "\E052";
124
- }
125
- .glyphicon-paperclip:before {
126
- content: "\E063";
127
- }
128
- .glyphicon-link:before {
129
- content: "\E051";
130
- }
131
- .glyphicon-arrow-up:before {
132
- content: "\E214";
133
- }
134
- .glyphicon-flash:before {
135
- content: "\E242";
136
- }
137
- .glyphicon-time:before {
138
- content: "\E055";
139
- }
140
- .glyphicon-volume-off:before {
141
- content: "\E183";
142
- }
143
- .glyphicon-volume-up:before {
144
- content: "\E185";
145
- }
146
- .glyphicon-hourglass:before {
147
- content: "\231B";
148
- }
149
- .glyphicon-random:before {
150
- content: "\E084";
151
- }
152
- .glyphicon-down-arrow:before {
153
- content: "\E213";
154
- }
155
- .glyphicon-signal:before {
156
- content: "\E080";
157
- }
158
- .glyphicon-crown:before {
159
- content: "\E362";
160
- }
161
- .glyphicon-dashboard:before {
162
- content: "\E332";
163
- }
164
- .glyphicon-show-lines:before {
165
- content: "\E159";
166
- }
167
- .glyphicon-user-conversation:before {
168
- content: "\E527";
169
- }
170
- .glyphicon-life-preserver:before {
171
- content: "\E308";
172
- }
173
- .glyphicon-conversation:before {
174
- content: "\E245";
175
- }
176
- .glyphicon-chat:before {
177
- content: "\E246";
178
- }
179
- .glyphicon-baby-formula:before {
180
- content: "\E492";
181
- }
182
- .glyphicon-stroller:before {
183
- content: "\E076";
184
- }
185
- .glyphicon-edit:before {
186
- content: "\E151";
187
- }
188
- .glyphicon-circle-question-mark:before {
189
- content: "\E195";
190
- }
191
- .glyphicon-resize-small:before {
192
- content: "\E215";
193
- }
194
- .glyphicon-shopping-bag:before {
195
- content: "\E351";
196
- }
197
- .glyphicon-address-book:before {
198
- content: "\E089";
199
- }
200
- .glyphicon-search:before {
201
- content: "\E028";
202
- }
203
- .glyphicon-lightbulb:before {
204
- content: "\E065";
205
- }
206
- .glyphicon-coffee-cup:before {
207
- content: "\E295";
208
- }
209
- .glyphicon-grid:before {
210
- content: "\E157";
211
- }
212
- .glyphicon-home:before {
213
- content: "\E021";
214
- }
215
- .glyphicon-target:before {
216
- content: "\E473";
217
- }
218
- .glyphicon-ban-circle:before {
219
- content: "\E200";
220
- }
221
- .glyphicon-right-arrow:before {
222
- content: "\E212";
223
- }
224
-
Binary file
Binary file
Binary file
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export * from "./components";