@lavalogic/scoria 0.37.7 → 0.37.8
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.
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
lang="ts"
|
|
5
5
|
module
|
|
6
6
|
>
|
|
7
|
+
import { browser } from '$app/environment';
|
|
7
8
|
import { DATAMatrix } from '../Helpers/Datamatrix.js';
|
|
8
9
|
|
|
9
10
|
// Frozen const map of scanner shortcut codes recognised by AlertModal.
|
|
@@ -16,18 +17,17 @@
|
|
|
16
17
|
} as const);
|
|
17
18
|
type AlertShortcut = (typeof AlertShortcuts)[keyof typeof AlertShortcuts];
|
|
18
19
|
|
|
19
|
-
// Barcode icons are
|
|
20
|
-
//
|
|
20
|
+
// Barcode icons are encoded once at module load (rather than per
|
|
21
|
+
// component instance) so opening multiple alerts is cheap.
|
|
21
22
|
//
|
|
22
|
-
// `DATAMatrix`
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const otherIcon = HAS_DOM ? DATAMatrix(AlertShortcuts.other) : '';
|
|
23
|
+
// `DATAMatrix` calls `document.createElement` internally, which does
|
|
24
|
+
// not exist during SvelteKit's server-render pass. The module loads
|
|
25
|
+
// in both environments; we gate the encoding on the `browser` flag so
|
|
26
|
+
// the server gets empty strings (the modal is hidden during SSR
|
|
27
|
+
// anyway) and the client gets the real SVGs after hydration.
|
|
28
|
+
const yesIcon = browser ? DATAMatrix(AlertShortcuts.yes) : '';
|
|
29
|
+
const noIcon = browser ? DATAMatrix(AlertShortcuts.no) : '';
|
|
30
|
+
const otherIcon = browser ? DATAMatrix(AlertShortcuts.other) : '';
|
|
31
31
|
</script>
|
|
32
32
|
|
|
33
33
|
<script lang="ts">
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
module
|
|
5
5
|
lang="ts"
|
|
6
6
|
>
|
|
7
|
+
import { browser } from '$app/environment';
|
|
7
8
|
import { DATAMatrix } from '../Helpers/Datamatrix.js';
|
|
8
9
|
import { passthrough } from '../Helpers/Helpers.svelte.js';
|
|
9
10
|
import { ColourSet } from '../scss/colours.js';
|
|
@@ -53,8 +54,16 @@
|
|
|
53
54
|
// Pre-compute barcode SVGs once per `buttons` array. Building a DataMatrix
|
|
54
55
|
// barcode is non-trivial; rebuilding inside the each-block re-runs the
|
|
55
56
|
// encoder on every render.
|
|
57
|
+
//
|
|
58
|
+
// `DATAMatrix` calls `document.createElement` internally, which is
|
|
59
|
+
// undefined during SvelteKit's server render. Returning `null` on the
|
|
60
|
+
// server keeps the SVG slots empty for SSR; the client re-renders with
|
|
61
|
+
// the real encoded payload after hydration.
|
|
56
62
|
const barcodeIcons = $derived.by(
|
|
57
|
-
() =>
|
|
63
|
+
() =>
|
|
64
|
+
buttons?.map((b) =>
|
|
65
|
+
b.barcodeValue != null && browser ? DATAMatrix(b.barcodeValue) : null
|
|
66
|
+
) ?? []
|
|
58
67
|
);
|
|
59
68
|
|
|
60
69
|
onMount(() => {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
module
|
|
5
5
|
lang="ts"
|
|
6
6
|
>
|
|
7
|
+
import { browser } from '$app/environment';
|
|
7
8
|
import { DATAMatrix } from '../../Helpers/Datamatrix.js';
|
|
8
9
|
import { useAsyncFlag } from '../../Helpers/AsyncFlag.svelte.js';
|
|
9
10
|
import { passthrough } from '../../Helpers/Helpers.svelte.js';
|
|
@@ -51,8 +52,16 @@
|
|
|
51
52
|
// Pre-compute barcode SVGs once per `buttons` array. Building a DataMatrix
|
|
52
53
|
// barcode is non-trivial; rebuilding inside the each-block re-runs the
|
|
53
54
|
// encoder on every render.
|
|
55
|
+
//
|
|
56
|
+
// `DATAMatrix` calls `document.createElement` internally, which is
|
|
57
|
+
// undefined during SvelteKit's server render. Returning `null` on the
|
|
58
|
+
// server keeps the SVG slots empty for SSR; the client re-renders with
|
|
59
|
+
// the real encoded payload after hydration.
|
|
54
60
|
const barcodeIcons = $derived.by(
|
|
55
|
-
() =>
|
|
61
|
+
() =>
|
|
62
|
+
buttons?.map((b) =>
|
|
63
|
+
b.barcodeValue != null && browser ? DATAMatrix(b.barcodeValue) : null
|
|
64
|
+
) ?? []
|
|
56
65
|
);
|
|
57
66
|
|
|
58
67
|
// Resolve each button's `isValid` once at the component level rather than
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lavalogic/scoria",
|
|
3
3
|
"description": "Svelte components used for the FloWMS Web Frontend",
|
|
4
|
-
"version": "0.37.
|
|
4
|
+
"version": "0.37.8",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "restricted"
|
|
7
7
|
},
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"svelte": "./dist/index.js"
|
|
24
24
|
},
|
|
25
25
|
"./scss/*": {
|
|
26
|
-
"sass": "./dist/scss
|
|
27
|
-
"style": "./dist/scss
|
|
28
|
-
"default": "./dist/scss
|
|
26
|
+
"sass": "./dist/scss/_*.scss",
|
|
27
|
+
"style": "./dist/scss/_*.scss",
|
|
28
|
+
"default": "./dist/scss/_*.scss"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|