memorio 1.0.0 → 1.0.2
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/index.js → index.js} +1 -1
- package/package.json +1 -1
- package/.editorconfig +0 -31
- package/.gitattributes +0 -1
- package/.github/CHANGELOG.md +0 -10
- package/.github/CITATION.cff +0 -24
- package/.github/CODEOWNERS +0 -1
- package/.github/CODE_OF_CONDUCT.md +0 -108
- package/.github/CONTRIBUTING.md +0 -108
- package/.github/COPYRIGHT.md +0 -9
- package/.github/FUNDING.yml +0 -16
- package/.github/HISTORY.md +0 -1
- package/.github/LICENSE.md +0 -21
- package/.github/SECURITY.md +0 -3
- package/.github/SUMMARY.md +0 -21
- package/.github/dependabot.yml +0 -11
- package/.github/documents/OBSERVER.md +0 -72
- package/.github/documents/STATE.md +0 -72
- package/.github/documents/STORE.md +0 -84
- package/.github/pull_request_template.md +0 -27
- package/.private/npm +0 -1
- package/.vscode/extension.json +0 -15
- package/.vscode/settings.json +0 -90
- package/config/dispatch.ts +0 -49
- package/config/global.ts +0 -36
- package/coverage/clover.xml +0 -260
- package/coverage/coverage-final.json +0 -10
- package/coverage/lcov-report/a51.memorio/config/dispatch.ts.html +0 -232
- package/coverage/lcov-report/a51.memorio/config/global.ts.html +0 -193
- package/coverage/lcov-report/a51.memorio/config/index.html +0 -131
- package/coverage/lcov-report/a51.memorio/dist/config/dispatch.js.html +0 -157
- package/coverage/lcov-report/a51.memorio/dist/config/global.js.html +0 -142
- package/coverage/lcov-report/a51.memorio/dist/config/index.html +0 -131
- package/coverage/lcov-report/a51.memorio/dist/functions/cache/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/dist/functions/cache/index.js.html +0 -103
- package/coverage/lcov-report/a51.memorio/dist/functions/observer/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/dist/functions/observer/index.js.html +0 -280
- package/coverage/lcov-report/a51.memorio/dist/functions/state/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/dist/functions/state/index.js.html +0 -460
- package/coverage/lcov-report/a51.memorio/dist/functions/store/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/dist/functions/store/index.js.html +0 -367
- package/coverage/lcov-report/a51.memorio/dist/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/dist/init.js.html +0 -106
- package/coverage/lcov-report/a51.memorio/functions/cache/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/functions/cache/index.ts.html +0 -142
- package/coverage/lcov-report/a51.memorio/functions/observer/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/functions/observer/index.ts.html +0 -448
- package/coverage/lcov-report/a51.memorio/functions/session/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/functions/session/index.ts.html +0 -409
- package/coverage/lcov-report/a51.memorio/functions/state/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/functions/state/index.ts.html +0 -682
- package/coverage/lcov-report/a51.memorio/functions/store/index.html +0 -116
- package/coverage/lcov-report/a51.memorio/functions/store/index.ts.html +0 -409
- package/coverage/lcov-report/a51.memorio/index.html +0 -131
- package/coverage/lcov-report/a51.memorio/index.ts.html +0 -88
- package/coverage/lcov-report/a51.memorio/init.ts.html +0 -115
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -206
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/session/index.html +0 -116
- package/coverage/lcov-report/session/index.ts.html +0 -571
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/state/index.html +0 -116
- package/coverage/lcov-report/state/index.ts.html +0 -1090
- package/coverage/lcov-report/store/index.html +0 -116
- package/coverage/lcov-report/store/index.ts.html +0 -556
- package/coverage/lcov.info +0 -518
- package/dist/README.md +0 -319
- package/dist/index.d.ts +0 -7
- package/dist/package.json +0 -98
- package/dist/types/cache.d.ts +0 -27
- package/dist/types/memorio.d.ts +0 -18
- package/dist/types/observer.d.ts +0 -47
- package/dist/types/session.d.ts +0 -91
- package/dist/types/state.d.ts +0 -71
- package/dist/types/store.d.ts +0 -91
- package/esbuild.config.mjs +0 -54
- package/eslint.config.mjs +0 -174
- package/examples/bg.jpg +0 -0
- package/examples/bootstrap.less +0 -92
- package/examples/favicon.ico +0 -0
- package/examples/index.htm +0 -65
- package/examples/javascript.js +0 -2
- package/examples/responsive.less +0 -47
- package/examples/styles.less +0 -169
- package/functions/cache/index.ts +0 -19
- package/functions/observer/index.ts +0 -121
- package/functions/session/index.ts +0 -108
- package/functions/state/index.ts +0 -199
- package/functions/store/index.ts +0 -108
- package/index.ts +0 -1
- package/init.ts +0 -12
- package/jest.config.mjs +0 -33
- package/jest.setup.js +0 -2
- package/tests/basic.test.ts +0 -50
- package/tests/cache.test.ts +0 -52
- package/tests/observer.test.ts +0 -62
- package/tests/setup.ts +0 -48
- package/tests/state.test.ts +0 -45
- package/tests/store.test.ts +0 -62
- package/tsconfig.json +0 -67
- /package/{.github/README.md → README.md} +0 -0
package/tests/cache.test.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach } from '@jest/globals'
|
|
2
|
-
import '../config/global.js'
|
|
3
|
-
import '../init'
|
|
4
|
-
|
|
5
|
-
describe('Cache Tests', () => {
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
// Clear cache if possible
|
|
8
|
-
try {
|
|
9
|
-
cache.clear()
|
|
10
|
-
} catch (e) {
|
|
11
|
-
// Ignore if clear is not available
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
test('should set and get cache values', () => {
|
|
16
|
-
cache.test = 'value'
|
|
17
|
-
expect(cache.test).toBe('value')
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test('should handle object values', () => {
|
|
21
|
-
const testObj = { key: 'value' }
|
|
22
|
-
cache.testObj = testObj
|
|
23
|
-
expect(cache.testObj).toEqual(testObj)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('should handle array values', () => {
|
|
27
|
-
const testArray = [1, 2, 3]
|
|
28
|
-
cache.testArray = testArray
|
|
29
|
-
expect(cache.testArray).toEqual(testArray)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('should handle nested objects', () => {
|
|
33
|
-
const nested = {
|
|
34
|
-
level1: {
|
|
35
|
-
level2: {
|
|
36
|
-
data: 'test'
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
cache.nested = nested
|
|
41
|
-
expect(cache.nested.level1.level2.data).toBe('test')
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('should handle persistence', () => {
|
|
45
|
-
cache.persistent = 'persist'
|
|
46
|
-
expect(cache.persistent).toBe('persist')
|
|
47
|
-
|
|
48
|
-
// Test removal
|
|
49
|
-
delete cache.persistent
|
|
50
|
-
expect(cache.persistent).toBeUndefined()
|
|
51
|
-
})
|
|
52
|
-
})
|
package/tests/observer.test.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, jest, beforeEach } from '@jest/globals'
|
|
2
|
-
import '../config/global.js'
|
|
3
|
-
|
|
4
|
-
// Initialize memorio object first
|
|
5
|
-
if (!globalThis.memorio) {
|
|
6
|
-
Object.defineProperty(globalThis, 'memorio', {
|
|
7
|
-
value: {},
|
|
8
|
-
writable: false,
|
|
9
|
-
configurable: false,
|
|
10
|
-
enumerable: false
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Then import other modules
|
|
15
|
-
import { buildProxy } from '../functions/state/index.js'
|
|
16
|
-
import '../init'
|
|
17
|
-
|
|
18
|
-
describe('Observer Tests', () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
// Reset state for each test
|
|
21
|
-
globalThis.state = buildProxy({}, () => { })
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('should observe state changes', async () => {
|
|
25
|
-
const mockCallback = jest.fn()
|
|
26
|
-
observer('state.test', mockCallback)
|
|
27
|
-
|
|
28
|
-
state.test = 'value'
|
|
29
|
-
|
|
30
|
-
// Observer events are async, so we need to wait
|
|
31
|
-
await new Promise(resolve => setTimeout(resolve, 100))
|
|
32
|
-
expect(mockCallback).toHaveBeenCalled()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test('should handle multiple observers', async () => {
|
|
36
|
-
const mockCallback1 = jest.fn()
|
|
37
|
-
const mockCallback2 = jest.fn()
|
|
38
|
-
|
|
39
|
-
observer('state.test', mockCallback1)
|
|
40
|
-
observer('state.test', mockCallback2)
|
|
41
|
-
|
|
42
|
-
state.test = 'value'
|
|
43
|
-
|
|
44
|
-
await new Promise(resolve => setTimeout(resolve, 100))
|
|
45
|
-
expect(mockCallback1).toHaveBeenCalled()
|
|
46
|
-
expect(mockCallback2).toHaveBeenCalled()
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('should observe nested state changes', async () => {
|
|
50
|
-
const mockCallback = jest.fn()
|
|
51
|
-
|
|
52
|
-
// Initialize nested state structure first
|
|
53
|
-
state.nested = {}
|
|
54
|
-
observer('state.nested.deep', mockCallback)
|
|
55
|
-
|
|
56
|
-
// Then set the deep value
|
|
57
|
-
state.nested.deep = 'value'
|
|
58
|
-
|
|
59
|
-
await new Promise(resolve => setTimeout(resolve, 100))
|
|
60
|
-
expect(mockCallback).toHaveBeenCalled()
|
|
61
|
-
})
|
|
62
|
-
})
|
package/tests/setup.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { jest } from '@jest/globals'
|
|
3
|
-
|
|
4
|
-
// Mock localStorage and sessionStorage
|
|
5
|
-
const localStorageMock = {
|
|
6
|
-
getItem: jest.fn(),
|
|
7
|
-
setItem: jest.fn(),
|
|
8
|
-
removeItem: jest.fn(),
|
|
9
|
-
clear: jest.fn(),
|
|
10
|
-
length: 0,
|
|
11
|
-
key: jest.fn()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const sessionStorageMock = {
|
|
15
|
-
getItem: jest.fn(),
|
|
16
|
-
setItem: jest.fn(),
|
|
17
|
-
removeItem: jest.fn(),
|
|
18
|
-
clear: jest.fn(),
|
|
19
|
-
length: 0,
|
|
20
|
-
key: jest.fn()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
Object.defineProperty(globalThis, 'localStorage', { value: localStorageMock })
|
|
24
|
-
Object.defineProperty(globalThis, 'sessionStorage', { value: sessionStorageMock })
|
|
25
|
-
|
|
26
|
-
// Mock navigator.storage
|
|
27
|
-
Object.defineProperty(globalThis, 'navigator', {
|
|
28
|
-
value: {
|
|
29
|
-
storage: {
|
|
30
|
-
estimate: () => Promise.resolve({ usage: 0, quota: 1000000 })
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
// Initialize global objects
|
|
36
|
-
globalThis.state = {}
|
|
37
|
-
globalThis.store = {
|
|
38
|
-
get: jest.fn(key => null),
|
|
39
|
-
set: jest.fn((key, value) => true),
|
|
40
|
-
remove: jest.fn(() => true),
|
|
41
|
-
removeAll: jest.fn(() => true),
|
|
42
|
-
delete: jest.fn(() => true),
|
|
43
|
-
clearAll: jest.fn(() => true),
|
|
44
|
-
quota: jest.fn(() => ({ usage: 0, quota: 1000000 })),
|
|
45
|
-
size: jest.fn(() => 0)
|
|
46
|
-
}
|
|
47
|
-
globalThis.cache = {}
|
|
48
|
-
globalThis.observer = jest.fn()
|
package/tests/state.test.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach } from '@jest/globals'
|
|
2
|
-
import '../config/global.js'
|
|
3
|
-
import { buildProxy } from '../functions/state/index.js'
|
|
4
|
-
import '../init'
|
|
5
|
-
|
|
6
|
-
describe('State Management', () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
// Reset state by creating a new proxy
|
|
9
|
-
globalThis.state = buildProxy({}, () => { })
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('should set and get state value', () => {
|
|
13
|
-
state.test = 'value'
|
|
14
|
-
expect(state.test).toBe('value')
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('should list all states', () => {
|
|
18
|
-
state.test1 = 'value1'
|
|
19
|
-
state.test2 = 'value2'
|
|
20
|
-
const list = state.list
|
|
21
|
-
expect(list).toHaveProperty('test1')
|
|
22
|
-
expect(list).toHaveProperty('test2')
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('should remove state', () => {
|
|
26
|
-
state.test = 'value'
|
|
27
|
-
state.remove('test')
|
|
28
|
-
expect(state.test).toBeUndefined()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('should remove all states', () => {
|
|
32
|
-
state.test1 = 'value1'
|
|
33
|
-
state.test2 = 'value2'
|
|
34
|
-
state.removeAll()
|
|
35
|
-
expect(state.list).toEqual({})
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('should lock object state', () => {
|
|
39
|
-
state.test = { prop: 'value' }
|
|
40
|
-
state.test.lock()
|
|
41
|
-
expect(() => {
|
|
42
|
-
state.test.newProp = 'value'
|
|
43
|
-
}).toThrow()
|
|
44
|
-
})
|
|
45
|
-
})
|
package/tests/store.test.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, jest, beforeEach } from '@jest/globals'
|
|
2
|
-
import '../config/global.js'
|
|
3
|
-
import '../init'
|
|
4
|
-
|
|
5
|
-
describe('Store Tests', () => {
|
|
6
|
-
let mockStore = {}
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
mockStore = {}
|
|
10
|
-
localStorage.clear()
|
|
11
|
-
jest.spyOn(localStorage, 'getItem').mockImplementation(key => mockStore[key] || null)
|
|
12
|
-
jest.spyOn(localStorage, 'setItem').mockImplementation((key, value) => {
|
|
13
|
-
mockStore[key] = value
|
|
14
|
-
})
|
|
15
|
-
jest.spyOn(localStorage, 'removeItem').mockImplementation(key => {
|
|
16
|
-
delete mockStore[key]
|
|
17
|
-
})
|
|
18
|
-
jest.spyOn(localStorage, 'clear').mockImplementation(() => {
|
|
19
|
-
mockStore = {}
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test('should set and get store values', () => {
|
|
24
|
-
const testValue = 'test value'
|
|
25
|
-
store.set('test', testValue)
|
|
26
|
-
expect(localStorage.setItem).toHaveBeenCalledWith('test', JSON.stringify(testValue))
|
|
27
|
-
expect(store.get('test')).toBe(testValue)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('should handle object values', () => {
|
|
31
|
-
const testObj = { key: 'value' }
|
|
32
|
-
store.set('test', testObj)
|
|
33
|
-
expect(localStorage.setItem).toHaveBeenCalledWith('test', JSON.stringify(testObj))
|
|
34
|
-
expect(store.get('test')).toEqual(testObj)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
test('should remove store item', () => {
|
|
38
|
-
store.set('test', 'value')
|
|
39
|
-
store.remove('test')
|
|
40
|
-
expect(localStorage.removeItem).toHaveBeenCalledWith('test')
|
|
41
|
-
expect(store.get('test')).toBeNull()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('should remove all store items', () => {
|
|
45
|
-
store.set('test1', 'value1')
|
|
46
|
-
store.set('test2', 'value2')
|
|
47
|
-
store.removeAll()
|
|
48
|
-
expect(localStorage.clear).toHaveBeenCalled()
|
|
49
|
-
expect(store.get('test1')).toBeNull()
|
|
50
|
-
expect(store.get('test2')).toBeNull()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('should get store size', () => {
|
|
54
|
-
mockStore = {}
|
|
55
|
-
store.removeAll()
|
|
56
|
-
store.set('test1', 'value1')
|
|
57
|
-
store.set('test2', 'value2')
|
|
58
|
-
const size = Object.keys(mockStore).length
|
|
59
|
-
expect(typeof size).toBe('number')
|
|
60
|
-
expect(size).toBe(2)
|
|
61
|
-
})
|
|
62
|
-
})
|
package/tsconfig.json
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
"es2022",
|
|
5
|
-
"dom"
|
|
6
|
-
],
|
|
7
|
-
"module": "NodeNext",
|
|
8
|
-
"moduleResolution": "NodeNext",
|
|
9
|
-
"types": [
|
|
10
|
-
"node"
|
|
11
|
-
],
|
|
12
|
-
"strict": true,
|
|
13
|
-
"noEmit": false,
|
|
14
|
-
"noImplicitThis": true,
|
|
15
|
-
"noUnusedLocals": true,
|
|
16
|
-
"importHelpers": true,
|
|
17
|
-
"skipLibCheck": true,
|
|
18
|
-
"allowSyntheticDefaultImports": true,
|
|
19
|
-
"forceConsistentCasingInFileNames": true,
|
|
20
|
-
"resolveJsonModule": true,
|
|
21
|
-
"isolatedModules": true,
|
|
22
|
-
"noImplicitAny": false,
|
|
23
|
-
"preserveConstEnums": true,
|
|
24
|
-
"removeComments": true,
|
|
25
|
-
"sourceMap": false,
|
|
26
|
-
"allowJs": true,
|
|
27
|
-
"esModuleInterop": true,
|
|
28
|
-
"strictNullChecks": false,
|
|
29
|
-
"strictPropertyInitialization": false,
|
|
30
|
-
"jsx": "react",
|
|
31
|
-
"moduleDetection": "force",
|
|
32
|
-
"baseUrl": ".",
|
|
33
|
-
"outDir": "./dist/",
|
|
34
|
-
"target": "es2022",
|
|
35
|
-
"rootDirs": [
|
|
36
|
-
"./"
|
|
37
|
-
],
|
|
38
|
-
"paths": {
|
|
39
|
-
"/*": [
|
|
40
|
-
"./*"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"include": [
|
|
45
|
-
"index.d.ts",
|
|
46
|
-
"./types/memorio.d.ts",
|
|
47
|
-
"./**/*.ts",
|
|
48
|
-
"./**/*.tsx"
|
|
49
|
-
],
|
|
50
|
-
"types": [
|
|
51
|
-
"node"
|
|
52
|
-
],
|
|
53
|
-
"typeRoots": [
|
|
54
|
-
"./types/*"
|
|
55
|
-
],
|
|
56
|
-
"exclude": [
|
|
57
|
-
"node_modules",
|
|
58
|
-
"private",
|
|
59
|
-
"archive",
|
|
60
|
-
"*backup",
|
|
61
|
-
"dist",
|
|
62
|
-
".old*",
|
|
63
|
-
".OLD*",
|
|
64
|
-
"#OLD*",
|
|
65
|
-
"@OLD*",
|
|
66
|
-
]
|
|
67
|
-
}
|
|
File without changes
|