@mideind/netskrafl-react 1.0.0-beta.6 → 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/dist/cjs/css/netskrafl.css +859 -177
  2. package/dist/cjs/index.js +206 -299
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/esm/css/netskrafl.css +859 -177
  5. package/dist/esm/index.js +205 -298
  6. package/dist/esm/index.js.map +1 -1
  7. package/package.json +13 -2
  8. package/.eslintignore +0 -8
  9. package/.eslintrc.json +0 -13
  10. package/rollup.config.js +0 -67
  11. package/src/components/index.ts +0 -2
  12. package/src/components/netskrafl/Netskrafl.stories.tsx +0 -66
  13. package/src/components/netskrafl/Netskrafl.tsx +0 -155
  14. package/src/components/netskrafl/Netskrafl.types.ts +0 -7
  15. package/src/components/netskrafl/index.ts +0 -2
  16. package/src/css/fonts.css +0 -4
  17. package/src/css/glyphs.css +0 -223
  18. package/src/css/main.css +0 -4
  19. package/src/css/skrafl-explo.css +0 -6636
  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 -4
  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 -187
  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/package.json CHANGED
@@ -1,14 +1,25 @@
1
1
  {
2
2
  "name": "@mideind/netskrafl-react",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.7",
4
4
  "description": "React UI for Netskrafl",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/mideind/netskrafl-react.git"
8
8
  },
9
+ "type": "module",
9
10
  "main": "dist/cjs/index.js",
10
11
  "module": "dist/esm/index.js",
11
- "types": "dist/types.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/types.d.ts",
15
+ "import": "./dist/esm/index.js",
16
+ "require": "./dist/cjs/index.js"
17
+ },
18
+ "./style.css": "./dist/esm/css/netskrafl.css"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
12
23
  "scripts": {
13
24
  "rollup": "rollup -c --bundleConfigAsCjs",
14
25
  "watch": "rollup -c --bundleConfigAsCjs -w",
package/.eslintignore DELETED
@@ -1,8 +0,0 @@
1
- node_modules
2
- dist
3
- .storybook
4
- storybook-static
5
- src/css
6
- src/fonts
7
- src/lib
8
- src/stories
package/.eslintrc.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "parser": "@typescript-eslint/parser",
3
- "extends": [
4
- "eslint:recommended",
5
- "plugin:@typescript-eslint/recommended",
6
- "plugin:prettier/recommended"
7
- ],
8
- "plugins": ["@typescript-eslint", "prettier"],
9
- "rules": {
10
- "prettier/prettier": "error",
11
- "@typescript-eslint/explicit-module-boundary-types": "off"
12
- }
13
- }
package/rollup.config.js DELETED
@@ -1,67 +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 postcssImport from "postcss-import";
12
- import path from "path";
13
-
14
- const packageJson = require("./package.json");
15
-
16
- export default [
17
- {
18
- input: "src/index.ts",
19
- output: [
20
- // CommonJS module
21
- {
22
- file: packageJson.main,
23
- format: "cjs",
24
- sourcemap: true,
25
- },
26
- // ECMAScript module
27
- {
28
- file: packageJson.module,
29
- format: "esm",
30
- sourcemap: true,
31
- },
32
- ],
33
- plugins: [
34
- peerDepsExternal(),
35
- alias({
36
- entries: [
37
- { find: '@', replacement: path.resolve(__dirname, 'src') }
38
- ]
39
- }),
40
- resolve({
41
- extensions: ['.js', '.jsx', '.ts', '.tsx']
42
- }),
43
- commonjs(),
44
- typescript({ tsconfig: "./tsconfig.json" }),
45
- postcss({
46
- plugins: [
47
- postcssImport(), // Handles @import concatenation
48
- // No cssnano or other aggressive minifiers here for now
49
- ],
50
- extract: 'css/netskrafl.css', // Output path for the bundled CSS relative to 'dist'
51
- // minimize: false, // Default is false, but explicitly stating it is fine
52
- // sourceMap: 'inline', // Or true for a separate .css.map file. 'inline' is good for dev.
53
- extensions: [".css"],
54
- modules: false,
55
- }),
56
- // terser(), // Uncomment for production builds
57
- ],
58
- external: ["react", "react-dom"],
59
- },
60
- {
61
- // Type declaration file (.d.ts)
62
- input: "src/index.ts",
63
- output: [{ file: "dist/types.d.ts", format: "es" }],
64
- external: [/\.css$/], // ignore .css file
65
- plugins: [dts.default()],
66
- },
67
- ];
@@ -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,155 +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
- const CSS_LINK_ID = "netskrafl-styles";
10
-
11
- const DEFAULT_STATE: GlobalState = {
12
- projectId: "netskrafl",
13
- firebaseAPIKey: "",
14
- databaseURL: "",
15
- firebaseSenderId: "",
16
- firebaseAppId: "",
17
- measurementId: "",
18
- userEmail: "",
19
- userId: "",
20
- userNick: "",
21
- userFullname: "",
22
- locale: "is_IS",
23
- isExplo: false,
24
- serverUrl: "",
25
- movesUrl: "",
26
- movesAccessKey: "",
27
- token: "",
28
- loginUrl: "",
29
- loginMethod: "",
30
- newUser: false,
31
- beginner: false,
32
- fairPlay: true,
33
- plan: "", // Not a friend
34
- hasPaid: false,
35
- ready: false,
36
- readyTimed: false,
37
- uiFullscreen: true,
38
- uiLandscape: false,
39
- runningLocal: false,
40
- };
41
-
42
- const mountForUser = async (state: GlobalState, tokenExpired?: () => void): Promise<HTMLDivElement> => {
43
- // Return a DOM tree containing a mounted Netskrafl UI
44
- // for the user specified in the state object
45
- const { userEmail } = state;
46
- if (!userEmail) {
47
- // console.error("No user specified for Netskrafl UI");
48
- throw new Error("No user specified for Netskrafl UI");
49
- }
50
- // Check whether we already have a mounted UI for this user
51
- const elemId = `netskrafl-user-${userEmail}`;
52
- const existing = document.getElementById(elemId);
53
- if (existing) {
54
- // console.log("Netskrafl UI already mounted for user", userEmail);
55
- return existing as HTMLDivElement;
56
- }
57
- // Create a new div element to hold the UI
58
- const root = document.createElement('div');
59
- root.id = elemId;
60
- root.className = "netskrafl-loading";
61
- // Attach the partially-mounted div to the document body
62
- // as a placeholder while the UI is being mounted
63
- document.body.appendChild(root);
64
- const loginResult = await main(state, root);
65
- if (loginResult === "success") {
66
- // The UI was successfully mounted
67
- root.className = "netskrafl-user";
68
- return root;
69
- } else if (loginResult === "expired") {
70
- // We need a new token from the Málstaður backend
71
- root.className = "netskrafl-expired";
72
- tokenExpired && tokenExpired(); // This causes a reload of the component
73
- return root;
74
- }
75
- // console.error("Failed to mount Netskrafl UI for user", userEmail);
76
- throw new Error("Failed to mount Netskrafl UI");
77
- }
78
-
79
- const NetskraflImpl = ({ state, tokenExpired }: INetskraflProps) => {
80
- const ref = React.createRef<HTMLDivElement>();
81
- const completeState = { ...DEFAULT_STATE, ...state };
82
- const { userEmail } = completeState;
83
-
84
- useEffect(() => {
85
- // Check if the stylesheet is already added by another instance
86
- if (document.getElementById(CSS_LINK_ID)) {
87
- // Optionally, you might want to increment a usage counter
88
- // and only remove the link when the counter is zero.
89
- // For simplicity, we'll assume one global link is fine.
90
- return;
91
- }
92
- const link = document.createElement("link");
93
- const styleUrl = `${window.location.origin}/static/css/netskrafl.css`;
94
- link.id = CSS_LINK_ID;
95
- link.rel = "stylesheet";
96
- link.type = "text/css";
97
- link.href = styleUrl;
98
- // Optional: for CORS, though if it's the same base domain, it might not be needed
99
- // link.crossOrigin = "anonymous";
100
- document.head.appendChild(link);
101
- }, []);
102
-
103
- useEffect(() => {
104
- // Load the Netskrafl (Mithril) UI for a new user
105
- // console.log("Mounting Netskrafl UI for user", userEmail);
106
- if (!userEmail) return;
107
- const container = ref.current;
108
- if (!container) {
109
- console.error("No container for Netskrafl UI");
110
- return;
111
- }
112
- const elemId = `netskrafl-user-${userEmail}`;
113
- if (container.firstElementChild?.id === elemId) {
114
- // Already exists and correctly mounted
115
- // console.log("Netskrafl UI already mounted with elemId", elemId);
116
- return;
117
- }
118
- try {
119
- mountForUser(completeState, tokenExpired).then((div) => {
120
- // Attach the div as a child of the container
121
- // instead of any previous children
122
- const container = ref.current;
123
- if (container) {
124
- container.innerHTML = "";
125
- container.appendChild(div);
126
- }
127
- });
128
- } catch (err) {
129
- console.error("Failed to mount Netskrafl UI for user", userEmail);
130
- const container = document.getElementById("netskrafl-container");
131
- if (container)
132
- container.innerHTML = "";
133
- }
134
- return () => {
135
- // console.log("Dismounting Netskrafl UI for user", userEmail);
136
- // Move the Netskrafl UI to a hidden div under the body element
137
- // when the component is unmounted
138
- const container = document.getElementById("netskrafl-container");
139
- const div = container?.firstElementChild;
140
- if (div?.id === elemId) {
141
- document.body.appendChild(div);
142
- }
143
- };
144
- }, [userEmail]);
145
-
146
- return (
147
- <div className="netskrafl">
148
- <div className="netskrafl-container" id="netskrafl-container" ref={ref}>
149
- { /* The Netskrafl single-page UI will be rendered here */ }
150
- </div>
151
- </div>
152
- );
153
- };
154
-
155
- 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,223 +0,0 @@
1
- /*
2
-
3
- Glyphs.css
4
-
5
- Style support for Glyphicons
6
-
7
- Copyright © 2025 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 assumed to be present on the host */
19
- src: url('/static/fonts/glyphicons-regular.eot') format('embedded-opentype'),
20
- url('/static/fonts/glyphicons-regular.woff') format('woff'),
21
- url('/static/fonts/glyphicons-regular.ttf') format('truetype');
22
- }
23
-
24
- .glyphicon {
25
- position: relative;
26
- top: 2px;
27
- display: inline-block;
28
- font-family: 'Glyphicons Regular';
29
- font-style: normal;
30
- font-weight: normal;
31
- line-height: 1;
32
- }
33
-
34
- .glyphicon-play:before {
35
- content: "\E174";
36
- }
37
- .glyphicon-exclamation-sign:before {
38
- content: "\E197";
39
- }
40
- .glyphicon-log-in:before {
41
- content: "\E387";
42
- }
43
- .glyphicon-log-out:before {
44
- content: "\E388";
45
- }
46
- .glyphicon-screenshot:before {
47
- content: "\E186";
48
- }
49
- .glyphicon-refresh:before {
50
- content: "\E082";
51
- }
52
- .glyphicon-forward:before {
53
- content: "\E177";
54
- }
55
- .glyphicon-fire:before {
56
- content: "\E023";
57
- }
58
- .glyphicon-ok:before {
59
- content: "\E207";
60
- }
61
- .glyphicon-remove:before {
62
- content: "\E208";
63
- }
64
- .glyphicon-info-sign:before {
65
- content: "\E196";
66
- }
67
- .glyphicon-cog:before {
68
- content: "\E137";
69
- }
70
- .glyphicon-chevron-left:before {
71
- content: "\E225";
72
- }
73
- .glyphicon-chevron-right:before {
74
- content: "\E224";
75
- }
76
- .glyphicon-circle-arrow-down:before {
77
- content: "\E220";
78
- }
79
- .glyphicon-download:before {
80
- content: "\E201";
81
- }
82
- .glyphicon-star:before {
83
- content: "\E050";
84
- }
85
- .glyphicon-flag:before {
86
- content: "\E267";
87
- }
88
- .glyphicon-flag-after:after {
89
- content: "\E267";
90
- }
91
- .glyphicon-bookmark:before {
92
- content: "\E073";
93
- }
94
- .glyphicon-star-empty:before {
95
- content: "\E049";
96
- }
97
- .glyphicon-hand-right:before {
98
- content: "\E346";
99
- }
100
- .glyphicon-hand-left:before {
101
- content: "\E347";
102
- }
103
- .glyphicon-thumbs-up:before {
104
- content: "\E344";
105
- }
106
- .glyphicon-thumbs-down:before {
107
- content: "\E345";
108
- }
109
- .glyphicon-remove-circle:before {
110
- content: "\E198";
111
- }
112
- .glyphicon-th:before {
113
- content: "\E157";
114
- }
115
- .glyphicon-user:before {
116
- content: "\E004";
117
- }
118
- .glyphicon-comment:before {
119
- content: "\E310";
120
- }
121
- .glyphicon-eye-open:before {
122
- content: "\E052";
123
- }
124
- .glyphicon-paperclip:before {
125
- content: "\E063";
126
- }
127
- .glyphicon-link:before {
128
- content: "\E051";
129
- }
130
- .glyphicon-arrow-up:before {
131
- content: "\E214";
132
- }
133
- .glyphicon-flash:before {
134
- content: "\E242";
135
- }
136
- .glyphicon-time:before {
137
- content: "\E055";
138
- }
139
- .glyphicon-volume-off:before {
140
- content: "\E183";
141
- }
142
- .glyphicon-volume-up:before {
143
- content: "\E185";
144
- }
145
- .glyphicon-hourglass:before {
146
- content: "\231B";
147
- }
148
- .glyphicon-random:before {
149
- content: "\E084";
150
- }
151
- .glyphicon-down-arrow:before {
152
- content: "\E213";
153
- }
154
- .glyphicon-signal:before {
155
- content: "\E080";
156
- }
157
- .glyphicon-crown:before {
158
- content: "\E362";
159
- }
160
- .glyphicon-dashboard:before {
161
- content: "\E332";
162
- }
163
- .glyphicon-show-lines:before {
164
- content: "\E159";
165
- }
166
- .glyphicon-user-conversation:before {
167
- content: "\E527";
168
- }
169
- .glyphicon-life-preserver:before {
170
- content: "\E308";
171
- }
172
- .glyphicon-conversation:before {
173
- content: "\E245";
174
- }
175
- .glyphicon-chat:before {
176
- content: "\E246";
177
- }
178
- .glyphicon-baby-formula:before {
179
- content: "\E492";
180
- }
181
- .glyphicon-stroller:before {
182
- content: "\E076";
183
- }
184
- .glyphicon-edit:before {
185
- content: "\E151";
186
- }
187
- .glyphicon-circle-question-mark:before {
188
- content: "\E195";
189
- }
190
- .glyphicon-resize-small:before {
191
- content: "\E215";
192
- }
193
- .glyphicon-shopping-bag:before {
194
- content: "\E351";
195
- }
196
- .glyphicon-address-book:before {
197
- content: "\E089";
198
- }
199
- .glyphicon-search:before {
200
- content: "\E028";
201
- }
202
- .glyphicon-lightbulb:before {
203
- content: "\E065";
204
- }
205
- .glyphicon-coffee-cup:before {
206
- content: "\E295";
207
- }
208
- .glyphicon-grid:before {
209
- content: "\E157";
210
- }
211
- .glyphicon-home:before {
212
- content: "\E021";
213
- }
214
- .glyphicon-target:before {
215
- content: "\E473";
216
- }
217
- .glyphicon-ban-circle:before {
218
- content: "\E200";
219
- }
220
- .glyphicon-right-arrow:before {
221
- content: "\E212";
222
- }
223
-
package/src/css/main.css DELETED
@@ -1,4 +0,0 @@
1
-
2
- @import "./fonts.css";
3
- @import "./glyphs.css";
4
- @import "./skrafl-explo.css";