slicejs-web-framework 3.4.3 → 3.5.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/.opencode/opencode.json +14 -14
- package/Slice/Components/Structural/ContextManager/ContextManager.js +422 -422
- package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +468 -468
- package/Slice/Components/Structural/Controller/Controller.js +1406 -1198
- package/Slice/Components/Structural/Debugger/Debugger.js +1503 -1503
- package/Slice/Components/Structural/EventManager/EventManager.js +651 -366
- package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +368 -30
- package/Slice/Components/Structural/LeakInspector/LeakInspector.js +296 -0
- package/Slice/Components/Structural/Logger/Logger.js +225 -225
- package/Slice/Components/Structural/Router/Router.js +775 -775
- package/Slice/Components/Structural/StylesManager/StylesManager.js +82 -82
- package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +106 -106
- package/Slice/Slice.js +663 -627
- package/Slice/tests/build-singleton.test.js +244 -244
- package/Slice/tests/bundle-v2-runtime-contract.test.js +738 -738
- package/Slice/tests/context-patch-use.test.js +95 -95
- package/Slice/tests/event-emitters.test.js +79 -0
- package/Slice/tests/event-registry.test.js +141 -0
- package/Slice/tests/fixtures/real-runtime-loader.mjs +21 -21
- package/Slice/tests/leak-orphans.test.js +131 -0
- package/Slice/tests/public-env-typed-accessors.test.js +66 -66
- package/api/index.js +308 -281
- package/api/utils/publicEnvResolver.js +123 -123
- package/package.json +44 -44
- package/sliceConfig.schema.json +10 -1
- package/src/sliceConfig.json +5 -1
- package/types/index.d.ts +12 -0
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
4
|
-
globalThis.alert = () => {};
|
|
5
|
-
|
|
6
|
-
const { default: Slice } = await import('../Slice.js');
|
|
7
|
-
|
|
8
|
-
function createSliceInstance() {
|
|
9
|
-
return new Slice({
|
|
10
|
-
paths: {},
|
|
11
|
-
themeManager: {},
|
|
12
|
-
stylesManager: {},
|
|
13
|
-
logger: {},
|
|
14
|
-
debugger: {},
|
|
15
|
-
loading: {},
|
|
16
|
-
events: {}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
test('slice.env.get / has / all', () => {
|
|
21
|
-
const s = createSliceInstance();
|
|
22
|
-
s.setPublicEnv({ SLICE_PUBLIC_API_URL: 'https://api.example.com', INTERNAL: 'hidden' });
|
|
23
|
-
|
|
24
|
-
assert.equal(s.env.get('SLICE_PUBLIC_API_URL'), 'https://api.example.com');
|
|
25
|
-
assert.equal(s.env.get('SLICE_PUBLIC_MISSING', 'fb'), 'fb');
|
|
26
|
-
assert.equal(s.env.has('SLICE_PUBLIC_API_URL'), true);
|
|
27
|
-
assert.equal(s.env.has('SLICE_PUBLIC_MISSING'), false);
|
|
28
|
-
assert.deepEqual(s.env.all(), { SLICE_PUBLIC_API_URL: 'https://api.example.com' }); // only SLICE_PUBLIC_*
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('slice.env.bool parses truthy strings and falls back', () => {
|
|
32
|
-
const s = createSliceInstance();
|
|
33
|
-
s.setPublicEnv({
|
|
34
|
-
SLICE_PUBLIC_ON: 'true',
|
|
35
|
-
SLICE_PUBLIC_ON2: 'YES',
|
|
36
|
-
SLICE_PUBLIC_ON3: '1',
|
|
37
|
-
SLICE_PUBLIC_OFF: 'false',
|
|
38
|
-
SLICE_PUBLIC_EMPTY: ''
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
assert.equal(s.env.bool('SLICE_PUBLIC_ON'), true);
|
|
42
|
-
assert.equal(s.env.bool('SLICE_PUBLIC_ON2'), true);
|
|
43
|
-
assert.equal(s.env.bool('SLICE_PUBLIC_ON3'), true);
|
|
44
|
-
assert.equal(s.env.bool('SLICE_PUBLIC_OFF'), false);
|
|
45
|
-
assert.equal(s.env.bool('SLICE_PUBLIC_EMPTY', true), true); // empty → fallback
|
|
46
|
-
assert.equal(s.env.bool('SLICE_PUBLIC_MISSING'), false); // missing → default false
|
|
47
|
-
assert.equal(s.env.bool('SLICE_PUBLIC_MISSING', true), true); // missing → custom fallback
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('slice.env.int parses integers and falls back', () => {
|
|
51
|
-
const s = createSliceInstance();
|
|
52
|
-
s.setPublicEnv({ SLICE_PUBLIC_TIMEOUT: '5000', SLICE_PUBLIC_BAD: 'nope' });
|
|
53
|
-
|
|
54
|
-
assert.equal(s.env.int('SLICE_PUBLIC_TIMEOUT'), 5000);
|
|
55
|
-
assert.equal(s.env.int('SLICE_PUBLIC_BAD', 10), 10); // non-numeric → fallback
|
|
56
|
-
assert.equal(s.env.int('SLICE_PUBLIC_MISSING', 42), 42); // missing → fallback
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('slice.env.list splits CSV, trims, drops empties', () => {
|
|
60
|
-
const s = createSliceInstance();
|
|
61
|
-
s.setPublicEnv({ SLICE_PUBLIC_MODELS: ' a , b ,, c ', SLICE_PUBLIC_EMPTY: '' });
|
|
62
|
-
|
|
63
|
-
assert.deepEqual(s.env.list('SLICE_PUBLIC_MODELS'), ['a', 'b', 'c']);
|
|
64
|
-
assert.deepEqual(s.env.list('SLICE_PUBLIC_EMPTY', ['x']), ['x']); // empty → fallback
|
|
65
|
-
assert.deepEqual(s.env.list('SLICE_PUBLIC_MISSING'), []); // missing → default []
|
|
66
|
-
});
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
|
|
4
|
+
globalThis.alert = () => {};
|
|
5
|
+
|
|
6
|
+
const { default: Slice } = await import('../Slice.js');
|
|
7
|
+
|
|
8
|
+
function createSliceInstance() {
|
|
9
|
+
return new Slice({
|
|
10
|
+
paths: {},
|
|
11
|
+
themeManager: {},
|
|
12
|
+
stylesManager: {},
|
|
13
|
+
logger: {},
|
|
14
|
+
debugger: {},
|
|
15
|
+
loading: {},
|
|
16
|
+
events: {}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
test('slice.env.get / has / all', () => {
|
|
21
|
+
const s = createSliceInstance();
|
|
22
|
+
s.setPublicEnv({ SLICE_PUBLIC_API_URL: 'https://api.example.com', INTERNAL: 'hidden' });
|
|
23
|
+
|
|
24
|
+
assert.equal(s.env.get('SLICE_PUBLIC_API_URL'), 'https://api.example.com');
|
|
25
|
+
assert.equal(s.env.get('SLICE_PUBLIC_MISSING', 'fb'), 'fb');
|
|
26
|
+
assert.equal(s.env.has('SLICE_PUBLIC_API_URL'), true);
|
|
27
|
+
assert.equal(s.env.has('SLICE_PUBLIC_MISSING'), false);
|
|
28
|
+
assert.deepEqual(s.env.all(), { SLICE_PUBLIC_API_URL: 'https://api.example.com' }); // only SLICE_PUBLIC_*
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('slice.env.bool parses truthy strings and falls back', () => {
|
|
32
|
+
const s = createSliceInstance();
|
|
33
|
+
s.setPublicEnv({
|
|
34
|
+
SLICE_PUBLIC_ON: 'true',
|
|
35
|
+
SLICE_PUBLIC_ON2: 'YES',
|
|
36
|
+
SLICE_PUBLIC_ON3: '1',
|
|
37
|
+
SLICE_PUBLIC_OFF: 'false',
|
|
38
|
+
SLICE_PUBLIC_EMPTY: ''
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
assert.equal(s.env.bool('SLICE_PUBLIC_ON'), true);
|
|
42
|
+
assert.equal(s.env.bool('SLICE_PUBLIC_ON2'), true);
|
|
43
|
+
assert.equal(s.env.bool('SLICE_PUBLIC_ON3'), true);
|
|
44
|
+
assert.equal(s.env.bool('SLICE_PUBLIC_OFF'), false);
|
|
45
|
+
assert.equal(s.env.bool('SLICE_PUBLIC_EMPTY', true), true); // empty → fallback
|
|
46
|
+
assert.equal(s.env.bool('SLICE_PUBLIC_MISSING'), false); // missing → default false
|
|
47
|
+
assert.equal(s.env.bool('SLICE_PUBLIC_MISSING', true), true); // missing → custom fallback
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('slice.env.int parses integers and falls back', () => {
|
|
51
|
+
const s = createSliceInstance();
|
|
52
|
+
s.setPublicEnv({ SLICE_PUBLIC_TIMEOUT: '5000', SLICE_PUBLIC_BAD: 'nope' });
|
|
53
|
+
|
|
54
|
+
assert.equal(s.env.int('SLICE_PUBLIC_TIMEOUT'), 5000);
|
|
55
|
+
assert.equal(s.env.int('SLICE_PUBLIC_BAD', 10), 10); // non-numeric → fallback
|
|
56
|
+
assert.equal(s.env.int('SLICE_PUBLIC_MISSING', 42), 42); // missing → fallback
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('slice.env.list splits CSV, trims, drops empties', () => {
|
|
60
|
+
const s = createSliceInstance();
|
|
61
|
+
s.setPublicEnv({ SLICE_PUBLIC_MODELS: ' a , b ,, c ', SLICE_PUBLIC_EMPTY: '' });
|
|
62
|
+
|
|
63
|
+
assert.deepEqual(s.env.list('SLICE_PUBLIC_MODELS'), ['a', 'b', 'c']);
|
|
64
|
+
assert.deepEqual(s.env.list('SLICE_PUBLIC_EMPTY', ['x']), ['x']); // empty → fallback
|
|
65
|
+
assert.deepEqual(s.env.list('SLICE_PUBLIC_MISSING'), []); // missing → default []
|
|
66
|
+
});
|