memorio 0.2.19 → 1.0.0
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/.editorconfig +31 -0
- package/.gitattributes +1 -0
- package/.private/npm +1 -0
- package/.vscode/extension.json +15 -0
- package/.vscode/settings.json +90 -0
- package/config/dispatch.ts +49 -0
- package/config/global.ts +36 -0
- package/coverage/clover.xml +260 -0
- package/coverage/coverage-final.json +10 -0
- package/coverage/lcov-report/a51.memorio/config/dispatch.ts.html +232 -0
- package/coverage/lcov-report/a51.memorio/config/global.ts.html +193 -0
- package/coverage/lcov-report/a51.memorio/config/index.html +131 -0
- package/coverage/lcov-report/a51.memorio/dist/config/dispatch.js.html +157 -0
- package/coverage/lcov-report/a51.memorio/dist/config/global.js.html +142 -0
- package/coverage/lcov-report/a51.memorio/dist/config/index.html +131 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/cache/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/cache/index.js.html +103 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/observer/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/observer/index.js.html +280 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/state/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/state/index.js.html +460 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/store/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/dist/functions/store/index.js.html +367 -0
- package/coverage/lcov-report/a51.memorio/dist/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/dist/init.js.html +106 -0
- package/coverage/lcov-report/a51.memorio/functions/cache/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/functions/cache/index.ts.html +142 -0
- package/coverage/lcov-report/a51.memorio/functions/observer/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/functions/observer/index.ts.html +448 -0
- package/coverage/lcov-report/a51.memorio/functions/session/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/functions/session/index.ts.html +409 -0
- package/coverage/lcov-report/a51.memorio/functions/state/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/functions/state/index.ts.html +682 -0
- package/coverage/lcov-report/a51.memorio/functions/store/index.html +116 -0
- package/coverage/lcov-report/a51.memorio/functions/store/index.ts.html +409 -0
- package/coverage/lcov-report/a51.memorio/index.html +131 -0
- package/coverage/lcov-report/a51.memorio/index.ts.html +88 -0
- package/coverage/lcov-report/a51.memorio/init.ts.html +115 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/session/index.html +116 -0
- package/coverage/lcov-report/session/index.ts.html +571 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/state/index.html +116 -0
- package/coverage/lcov-report/state/index.ts.html +1090 -0
- package/coverage/lcov-report/store/index.html +116 -0
- package/coverage/lcov-report/store/index.ts.html +556 -0
- package/coverage/lcov.info +518 -0
- package/dist/README.md +319 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/package.json +98 -0
- package/dist/types/cache.d.ts +27 -0
- package/dist/types/memorio.d.ts +18 -0
- package/dist/types/observer.d.ts +47 -0
- package/dist/types/session.d.ts +91 -0
- package/dist/types/state.d.ts +71 -0
- package/dist/types/store.d.ts +91 -0
- package/esbuild.config.mjs +54 -0
- package/eslint.config.mjs +174 -0
- package/examples/bg.jpg +0 -0
- package/examples/bootstrap.less +92 -0
- package/examples/favicon.ico +0 -0
- package/examples/index.htm +65 -0
- package/examples/javascript.js +2 -0
- package/examples/responsive.less +47 -0
- package/examples/styles.less +169 -0
- package/functions/cache/index.ts +19 -0
- package/functions/observer/index.ts +121 -0
- package/functions/session/index.ts +108 -0
- package/functions/state/index.ts +199 -0
- package/functions/store/index.ts +108 -0
- package/index.ts +1 -0
- package/init.ts +12 -0
- package/jest.config.mjs +33 -0
- package/jest.setup.js +2 -0
- package/package.json +4 -10
- package/tests/basic.test.ts +50 -0
- package/tests/cache.test.ts +52 -0
- package/tests/observer.test.ts +62 -0
- package/tests/setup.ts +48 -0
- package/tests/state.test.ts +45 -0
- package/tests/store.test.ts +62 -0
- package/tsconfig.json +67 -0
- package/index.js +0 -1
- /package/{CHANGELOG.md → .github/CHANGELOG.md} +0 -0
- /package/{CITATION.cff → .github/CITATION.cff} +0 -0
- /package/{CODEOWNERS → .github/CODEOWNERS} +0 -0
- /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
- /package/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +0 -0
- /package/{COPYRIGHT.md → .github/COPYRIGHT.md} +0 -0
- /package/{FUNDING.yml → .github/FUNDING.yml} +0 -0
- /package/{HISTORY.md → .github/HISTORY.md} +0 -0
- /package/{LICENSE.md → .github/LICENSE.md} +0 -0
- /package/{README.md → .github/README.md} +0 -0
- /package/{SECURITY.md → .github/SECURITY.md} +0 -0
- /package/{SUMMARY.md → .github/SUMMARY.md} +0 -0
- /package/{dependabot.yml → .github/dependabot.yml} +0 -0
- /package/{documents → .github/documents}/OBSERVER.md +0 -0
- /package/{documents → .github/documents}/STATE.md +0 -0
- /package/{documents → .github/documents}/STORE.md +0 -0
- /package/{pull_request_template.md → .github/pull_request_template.md} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { describe, test, expect } from '@jest/globals'
|
|
2
|
+
import '../init'
|
|
3
|
+
|
|
4
|
+
// Basic state management tests
|
|
5
|
+
describe('Basic State Tests', () => {
|
|
6
|
+
test('State should exist globally', () => {
|
|
7
|
+
expect(globalThis.state).toBeDefined()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
test('Should set and get a simple value', () => {
|
|
11
|
+
state.testValue = 'hello'
|
|
12
|
+
expect(state.testValue).toBe('hello')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('Should handle number values', () => {
|
|
16
|
+
state.number = 42
|
|
17
|
+
expect(state.number).toBe(42)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
// Object state tests
|
|
22
|
+
describe('Object State Tests', () => {
|
|
23
|
+
test('Should handle object values', () => {
|
|
24
|
+
state.obj = { key: 'value' }
|
|
25
|
+
expect(state.obj.key).toBe('value')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('Should handle nested objects', () => {
|
|
29
|
+
state.nested = {
|
|
30
|
+
level1: {
|
|
31
|
+
level2: 'deep'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
expect(state.nested.level1.level2).toBe('deep')
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// Array state tests
|
|
39
|
+
describe('Array State Tests', () => {
|
|
40
|
+
test('Should handle array values', () => {
|
|
41
|
+
state.array = [1, 2, 3]
|
|
42
|
+
expect(state.array).toEqual([1, 2, 3])
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('Should allow array mutations', () => {
|
|
46
|
+
state.array = [1, 2]
|
|
47
|
+
state.array.push(3)
|
|
48
|
+
expect(state.array).toEqual([1, 2, 3])
|
|
49
|
+
})
|
|
50
|
+
})
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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()
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(()=>{var c={name:"memorio",version:"0.2.19",type:"module",main:"index.js",scripts:{build:"node ./esbuild.config.mjs",watch:"esbuild init.ts --bundle --outdir=dist --serve","-----------":"",test:"set NODE_OPTIONS=--experimental-vm-modules && jest","test:watch":"set NODE_OPTIONS=--experimental-vm-modules && jest --watch","test:coverage":"set NODE_OPTIONS=--experimental-vm-modules && jest --coverage","test:watchAll":"set NODE_OPTIONS=--experimental-vm-modules && jest --watchAll",tsc:"tsc -b .",eslint:"eslint .",updates:"npx npm-check-updates -u && npm i","----------":"","publish:npm":"npm run build && npm publish ./dist"},types:"index.d.ts",typings:"./types/*",description:"Memorio, State + Observer and Store for a easy life ",license:"MIT",deprecated:!1,preferGlobal:!0,target:"node",copyright:"Dario Passariello, BigLogic ca - a51.dev is a BigLogic project",homepage:"https://a51.gitbook.io/memorio",author:{name:"Dario Passariello",url:"https://dario.passariello.ca/",email:"dariopassariello@gmail.com"},support:{name:"Dario Passariello",url:"https://github.com/passariello/",email:"dariopassariello@gmail.com"},contributors:[{name:"Dario Passariello",email:"dariopassarielloa@gmail.com"},{name:"Valeria Cala Scaglitta",email:"valeriacalascaglitta@gmail.com"}],globals:{memorio:{}},keywords:["biglogic","a51","memorio","state","store","observer","dario","passariello"],repository:{type:"git",url:"git+https://github.com/a51-dev/a51.memorio.git",help:"https://github.com/a51-dev/a51.memorio#readme"},bugs:{url:"https://github.com/a51-dev/a51.memorio/issues"},funding:[{type:"patreon",url:"https://www.patreon.com/passariello"}],typing:["types/*"],dependencies:{"dphelper.types":"0.0.19"},devDependencies:{"@eslint/js":"9.34.0","@types/jest":"30.0.0","@types/node":"^24.3.0","@typescript-eslint/eslint-plugin":"8.40.0","@typescript-eslint/parser":"8.40.0","dphelper.types":"0.0.19",esbuild:"^0.25.9","esbuild-plugin-clean":"^1.0.1","esbuild-plugin-copy":"^2.1.1",eslint:"9.34.0",jest:"30.0.5","jest-environment-jsdom":"30.0.5","ts-jest":"29.4.1","ts-loader":"^9.5.2","ts-node":"10.9.2",tslib:"^2.8.1",typescript:"5.9.2"}};Object.defineProperty(globalThis,"memorio",{value:{},writable:!1,configurable:!1,enumerable:!1});Object.defineProperty(globalThis,"events",{value:{},writable:!0,configurable:!1,enumerable:!1});Object.defineProperty(memorio,"version",{writable:!1,configurable:!1,enumerable:!1,value:c.version});Object.defineProperty(memorio,"dispatch",{writable:!1,configurable:!1,enumerable:!1,value:{set:(e,t={})=>{dispatchEvent(new CustomEvent(String(e),t))},listen:(e,t=null,i=!1)=>{observer.list?.[e]?.length>0&&observer.remove(e);let l=r=>t?setTimeout(()=>t(r),1):null;globalThis.addEventListener(e,l),globalThis.events[e]=l},remove:e=>{globalThis.removeEventListener(e,globalThis.events[e]),delete globalThis.events[e]}}});Object.defineProperty(memorio,"objPath",{writable:!1,configurable:!1,enumerable:!1,value:(e,t,i=".")=>t.concat(e).join(i)});var u=(e,t,i=[])=>{let l=r=>{let o=r.split(".");o.forEach((s,n)=>{let a=o.slice(0,n+1).join(".");globalThis.memorio.dispatch.set(a,{detail:{name:a}})})};return new Proxy(e,{get(r,o){if(o==="list"){let s={};for(let n in r)typeof r[n]!="function"&&!["list","remove","removeAll"].includes(n)&&(s[n]=r[n]);return s}if(o==="remove")return function(s){return s in r&&!["list","remove","removeAll"].includes(s)?(delete r[s],!0):!1};if(o==="removeAll")return function(){for(let s in r)typeof r[s]!="function"&&!["list","remove","removeAll"].includes(s)&&delete r[s];return!0};if(Object.isFrozen(r[o]))return r[o];try{let s=Reflect.get(r,o);return s&&typeof s=="object"&&["Array","Object"].includes(s.constructor.name)?u(s,t,i.concat(o)):s}catch(s){console.error("Error: ",s);return}},set(r,o,s){if(r[o]&&typeof r[o]=="object"&&Object.isFrozen(r[o])){console.error(`Error: state '${o}' is locked`);return}try{let n=globalThis.memorio.objPath(o,i);return t({action:"set",path:n,target:r,newValue:s,previousValue:Reflect.get(r,o)}),l("state."+n),Reflect.set(r,o,s),r[o]&&typeof r[o]=="object"&&Reflect.defineProperty(r[o],"lock",{value(){Object.defineProperty(r,o,{writable:!1,enumerable:!1}),Object.freeze(r[o])}}),!0}catch(n){return console.error("Error in set trap:",n),!1}},deleteProperty(r,o){try{let s=globalThis.memorio.objPath(o,i);return t({action:"delete",path:s,target:r}),Reflect.deleteProperty(r,o)}catch(s){return console.error("Error in deleteProperty trap:",s),!1}}})},g={};globalThis?.state?globalThis.state=state:globalThis.state=u(g,()=>{});var f=new WeakSet;f.add(state);setInterval(()=>{if(!f.has(state)){alert("memorio State is compromised, check if you override it and please reload the page");for(let e=1;e<99999;e++)clearInterval(e);stop()}},1e3);Object.defineProperty(globalThis,"state",{enumerable:!1,configurable:!1});globalThis.observer||(globalThis.observer=null);Object.defineProperty(globalThis,"observer",{enumerable:!1});observer=(e,t=null,i=!0)=>{if((r=>r.split(".")[0]!=="state"?(console.error(`Observer Error: You need to declare 'state.' or 'store.'. The '${r}' string is incorrect!`),!1):!0)(e)){if(!e&&!t){console.error("Observer Error: You need to setup observer correctly, Some parameters are missed!");return}if(!e&&t){console.error("Observer Error: You need to declare what state need to be monitored as string like 'state.test'.");return}if(e&&!t){globalThis.memorio.dispatch.listen(String(e),{detail:{name:String(e)}}),console.debug("called: ",e);return}if(e&&t){if(typeof e!="string"||typeof t!="function"){console.error("Observer Error: name of state need to be a 'string' like 'state.test' and the callback need to be a 'function'");return}globalThis.memorio.dispatch.listen(e,t,i);return}}};Object.defineProperties(observer,{list:{get:()=>globalThis.events},remove:{value:e=>{e&&(globalThis.events[e]="")}},removeAll:{get:()=>{Object.entries(observer.list).forEach(e=>{globalThis.events[e[0]]})}}});Object.freeze(observer);Object.defineProperty(globalThis,"store",{value:new Proxy({},{}),enumerable:!1,configurable:!1});Object.defineProperties(store,{get:{value(e){if(e)try{let t=localStorage.getItem(e);return t&&JSON.parse(t)}catch(t){console.error(`Error parsing store item '${e}':`,t)}}},set:{value(e,t){if(e)try{t==null?localStorage.setItem(e,JSON.stringify(null)):typeof t=="object"||typeof t=="number"||typeof t=="boolean"||typeof t=="string"?localStorage.setItem(e,JSON.stringify(t)):typeof t=="function"&&console.error("It's not secure to store functions.")}catch(i){console.error(`Error setting store item '${e}':`,i)}}},remove:{value(e){if(e&&localStorage.getItem(e))return localStorage.removeItem(e),!0}},delete:{value(e){store.remove(e)}},removeAll:{value(){return localStorage.clear(),!0}},clearAll:{value(){return store.removeAll(),!0}},quota:{value(){"storage"in navigator&&"estimate"in navigator.storage&&navigator.storage.estimate().then(({usage:e,quota:t})=>{e&&t&&console.debug(`Using ${e/1024} out of ${t/1024} Mb.`)}).catch(e=>{console.error("Error estimating quota:",e)})}},size:{value(){let e=0;for(let t in localStorage)if(localStorage.hasOwnProperty(t)){let i=localStorage.getItem(t);i&&(e+=i.length)}return e}}});Object.freeze(store);Object.defineProperty(globalThis,"session",{value:new Proxy({},{}),enumerable:!1,configurable:!1});Object.defineProperties(session,{get:{value(e){if(e)try{let t=sessionStorage.getItem(e);return t&&JSON.parse(t)}catch(t){console.error(`Error parsing session item '${e}':`,t)}}},set:{value(e,t){if(e)try{t==null?sessionStorage.setItem(e,JSON.stringify(null)):typeof t=="object"||typeof t=="number"||typeof t=="boolean"||typeof t=="string"?sessionStorage.setItem(e,JSON.stringify(t)):typeof t=="function"&&console.error("It's not secure to session functions.")}catch(i){console.error(`Error setting session item '${e}':`,i)}}},remove:{value(e){if(e&&sessionStorage.getItem(e))return sessionStorage.removeItem(e),!0}},delete:{value(e){session.remove(e)}},removeAll:{value(){return sessionStorage.clear(),!0}},clearAll:{value(){return session.removeAll(),!0}},quota:{value(){"storage"in navigator&&"estimate"in navigator.storage&&navigator.storage.estimate().then(({usage:e,quota:t})=>{e&&t&&console.debug(`Using ${e/1024} out of ${t/1024} Mb.`)}).catch(e=>{console.error("Error estimating quota:",e)})}},size:{value(){let e=0;for(let t in sessionStorage)if(sessionStorage.hasOwnProperty(t)){let i=sessionStorage.getItem(t);i&&(e+=i.length)}return e}}});Object.freeze(session);Object.defineProperty(window,"cache",{value:new Proxy({},{}),enumerable:!1,configurable:!1});})();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|