@open-mercato/shared 0.10.1-develop.8152.1.948c1eb458 → 0.10.1-develop.8159.1.71854b31a8
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/lib/version.js
CHANGED
package/dist/lib/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/version.ts"],
|
|
4
|
-
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.10.1-develop.
|
|
4
|
+
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.10.1-develop.8159.1.71854b31a8';\nexport const appVersion = APP_VERSION;\n"],
|
|
5
5
|
"mappings": "AACO,MAAM,cAAc;AACpB,MAAM,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/shared",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.8159.1.71854b31a8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"@mikro-orm/core": "^7.1.14",
|
|
131
131
|
"@mikro-orm/decorators": "^7.1.14",
|
|
132
132
|
"@mikro-orm/postgresql": "^7.1.14",
|
|
133
|
-
"@open-mercato/cache": "0.10.1-develop.
|
|
133
|
+
"@open-mercato/cache": "0.10.1-develop.8159.1.71854b31a8",
|
|
134
134
|
"@types/html-to-text": "^9.0.4",
|
|
135
135
|
"@types/sanitize-html": "^2.16.1",
|
|
136
136
|
"dotenv": "^17.4.2",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
import {
|
|
3
|
+
readJsonFromLocalStorage,
|
|
4
|
+
writeJsonToLocalStorage,
|
|
5
|
+
removeLocalStorageKey,
|
|
6
|
+
} from '../safeLocalStorage'
|
|
7
|
+
|
|
8
|
+
describe('safeLocalStorage (browser environment)', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
window.localStorage.clear()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('round-trips a value through write then read', () => {
|
|
14
|
+
writeJsonToLocalStorage('test:a', { foo: 'bar' })
|
|
15
|
+
expect(readJsonFromLocalStorage('test:a', null)).toEqual({ foo: 'bar' })
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('returns the fallback when the key is missing', () => {
|
|
19
|
+
expect(readJsonFromLocalStorage('test:missing', 'fallback')).toBe('fallback')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('returns the fallback on malformed JSON instead of throwing', () => {
|
|
23
|
+
window.localStorage.setItem('test:bad', '{not json')
|
|
24
|
+
expect(readJsonFromLocalStorage('test:bad', 'fallback')).toBe('fallback')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('removes a stored key', () => {
|
|
28
|
+
writeJsonToLocalStorage('test:b', { foo: 'bar' })
|
|
29
|
+
removeLocalStorageKey('test:b')
|
|
30
|
+
expect(window.localStorage.getItem('test:b')).toBeNull()
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readJsonFromLocalStorage,
|
|
3
|
+
writeJsonToLocalStorage,
|
|
4
|
+
removeLocalStorageKey,
|
|
5
|
+
} from '../safeLocalStorage'
|
|
6
|
+
|
|
7
|
+
// Deliberately no `@jest-environment jsdom` override: this suite runs under the
|
|
8
|
+
// package's default `testEnvironment: 'node'` (jest.config.cjs), the same runtime
|
|
9
|
+
// shape as Next.js SSR. There is no `window` global here. If a guard regressed to
|
|
10
|
+
// touch `window.localStorage` unconditionally, every call below would throw
|
|
11
|
+
// `ReferenceError: window is not defined` instead of degrading gracefully — this
|
|
12
|
+
// is what let the Node ExperimentalWarning / SSR-safety report (#8408) go
|
|
13
|
+
// unverified by CI.
|
|
14
|
+
describe('safeLocalStorage (no window / SSR-like environment)', () => {
|
|
15
|
+
it('has no window global in this environment', () => {
|
|
16
|
+
expect(typeof window).toBe('undefined')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('readJsonFromLocalStorage returns the fallback without throwing', () => {
|
|
20
|
+
expect(readJsonFromLocalStorage('any-key', 'fallback')).toBe('fallback')
|
|
21
|
+
const fallback = { foo: 'bar' }
|
|
22
|
+
expect(readJsonFromLocalStorage('other-key', fallback)).toBe(fallback)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('writeJsonToLocalStorage is a no-op without throwing', () => {
|
|
26
|
+
expect(() => writeJsonToLocalStorage('any-key', { foo: 'bar' })).not.toThrow()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('removeLocalStorageKey is a no-op without throwing', () => {
|
|
30
|
+
expect(() => removeLocalStorageKey('any-key')).not.toThrow()
|
|
31
|
+
})
|
|
32
|
+
})
|