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.
Files changed (27) hide show
  1. package/.opencode/opencode.json +14 -14
  2. package/Slice/Components/Structural/ContextManager/ContextManager.js +422 -422
  3. package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +468 -468
  4. package/Slice/Components/Structural/Controller/Controller.js +1406 -1198
  5. package/Slice/Components/Structural/Debugger/Debugger.js +1503 -1503
  6. package/Slice/Components/Structural/EventManager/EventManager.js +651 -366
  7. package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +368 -30
  8. package/Slice/Components/Structural/LeakInspector/LeakInspector.js +296 -0
  9. package/Slice/Components/Structural/Logger/Logger.js +225 -225
  10. package/Slice/Components/Structural/Router/Router.js +775 -775
  11. package/Slice/Components/Structural/StylesManager/StylesManager.js +82 -82
  12. package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +106 -106
  13. package/Slice/Slice.js +663 -627
  14. package/Slice/tests/build-singleton.test.js +244 -244
  15. package/Slice/tests/bundle-v2-runtime-contract.test.js +738 -738
  16. package/Slice/tests/context-patch-use.test.js +95 -95
  17. package/Slice/tests/event-emitters.test.js +79 -0
  18. package/Slice/tests/event-registry.test.js +141 -0
  19. package/Slice/tests/fixtures/real-runtime-loader.mjs +21 -21
  20. package/Slice/tests/leak-orphans.test.js +131 -0
  21. package/Slice/tests/public-env-typed-accessors.test.js +66 -66
  22. package/api/index.js +308 -281
  23. package/api/utils/publicEnvResolver.js +123 -123
  24. package/package.json +44 -44
  25. package/sliceConfig.schema.json +10 -1
  26. package/src/sliceConfig.json +5 -1
  27. 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
+ });