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

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/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import React from 'react';
2
3
 
3
4
  interface GlobalState {
@@ -36,6 +37,6 @@ interface INetskraflProps {
36
37
  tokenExpired?: () => void;
37
38
  }
38
39
 
39
- declare const Netskrafl: React.NamedExoticComponent<INetskraflProps>;
40
+ declare const Netskrafl: React.MemoExoticComponent<({ state, tokenExpired }: INetskraflProps) => react_jsx_runtime.JSX.Element>;
40
41
 
41
42
  export { type INetskraflProps, Netskrafl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mideind/netskrafl-react",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.6",
4
4
  "description": "React UI for Netskrafl",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,6 +34,7 @@
34
34
  "@storybook/test": "^8.4.4",
35
35
  "@types/mithril": "^2.2.7",
36
36
  "@types/react": "^18.3.12",
37
+ "postcss-import": "^16.1.0",
37
38
  "rollup": "^4.27.1",
38
39
  "rollup-plugin-dts": "^6.1.1",
39
40
  "rollup-plugin-peer-deps-external": "^2.2.4",
package/rollup.config.js CHANGED
@@ -5,9 +5,10 @@ import alias from '@rollup/plugin-alias';
5
5
  import commonjs from "@rollup/plugin-commonjs";
6
6
  import typescript from "@rollup/plugin-typescript";
7
7
  import dts from "rollup-plugin-dts";
8
- import terser from "@rollup/plugin-terser";
8
+ // import terser from "@rollup/plugin-terser";
9
9
  import peerDepsExternal from "rollup-plugin-peer-deps-external";
10
10
  import postcss from "rollup-plugin-postcss";
11
+ import postcssImport from "postcss-import";
11
12
  import path from "path";
12
13
 
13
14
  const packageJson = require("./package.json");
@@ -31,11 +32,6 @@ export default [
31
32
  ],
32
33
  plugins: [
33
34
  peerDepsExternal(),
34
- postcss({
35
- extensions: [".css"],
36
- modules: false,
37
- // extract: "index.css",
38
- }),
39
35
  alias({
40
36
  entries: [
41
37
  { find: '@', replacement: path.resolve(__dirname, 'src') }
@@ -46,7 +42,18 @@ export default [
46
42
  }),
47
43
  commonjs(),
48
44
  typescript({ tsconfig: "./tsconfig.json" }),
49
- terser(),
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
50
57
  ],
51
58
  external: ["react", "react-dom"],
52
59
  },
@@ -6,9 +6,7 @@ import { main } from "@/mithril/page";
6
6
 
7
7
  export { type INetskraflProps };
8
8
 
9
- import "@/css/fonts.css";
10
- import "@/css/glyphs.css";
11
- import "@/css/skrafl-explo.css";
9
+ const CSS_LINK_ID = "netskrafl-styles";
12
10
 
13
11
  const DEFAULT_STATE: GlobalState = {
14
12
  projectId: "netskrafl",
@@ -78,11 +76,30 @@ const mountForUser = async (state: GlobalState, tokenExpired?: () => void): Prom
78
76
  throw new Error("Failed to mount Netskrafl UI");
79
77
  }
80
78
 
81
- const NetskraflImpl: React.FC<INetskraflProps> = ({ state, tokenExpired }) => {
79
+ const NetskraflImpl = ({ state, tokenExpired }: INetskraflProps) => {
82
80
  const ref = React.createRef<HTMLDivElement>();
83
81
  const completeState = { ...DEFAULT_STATE, ...state };
84
82
  const { userEmail } = completeState;
85
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
+
86
103
  useEffect(() => {
87
104
  // Load the Netskrafl (Mithril) UI for a new user
88
105
  // console.log("Mounting Netskrafl UI for user", userEmail);
@@ -4,7 +4,7 @@
4
4
 
5
5
  Style support for Glyphicons
6
6
 
7
- Copyright © 2024 Miðeind ehf.
7
+ Copyright © 2025 Miðeind ehf.
8
8
  Author: Vilhjalmur Thorsteinsson
9
9
 
10
10
  The Creative Commons Attribution-NonCommercial 4.0
@@ -15,11 +15,10 @@
15
15
 
16
16
  @font-face {
17
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');
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');
23
22
  }
24
23
 
25
24
  .glyphicon {
@@ -0,0 +1,4 @@
1
+
2
+ @import "./fonts.css";
3
+ @import "./glyphs.css";
4
+ @import "./skrafl-explo.css";
package/src/index.ts CHANGED
@@ -1,2 +1,4 @@
1
1
 
2
+ import "@/css/main.css";
3
+
2
4
  export * from "./components";
@@ -120,6 +120,7 @@ async function loadMessages(locale: string) {
120
120
  const messages = await request<Messages>({
121
121
  method: "GET",
122
122
  url: "/static/assets/messages.json",
123
+ withCredentials: false, // Cookies are not allowed for CORS request
123
124
  });
124
125
  setLocale(locale, messages);
125
126
  }