@makroz/web 1.2.4 → 1.2.6-rc14
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/README.md +1 -1
- package/bin/mk-update.js +249 -0
- package/dist/auth/AuthStorageAdapter.d.ts +74 -0
- package/dist/auth/AuthStorageAdapter.d.ts.map +1 -0
- package/dist/auth/AuthStorageAdapter.js +140 -0
- package/dist/auth/AuthStorageAdapter.js.map +1 -0
- package/dist/auth/MkAuthProvider.d.ts +11 -2
- package/dist/auth/MkAuthProvider.d.ts.map +1 -1
- package/dist/auth/MkAuthProvider.js +15 -25
- package/dist/auth/MkAuthProvider.js.map +1 -1
- package/dist/components/MkFileUpload.d.ts.map +1 -1
- package/dist/components/MkFileUpload.js +36 -2
- package/dist/components/MkFileUpload.js.map +1 -1
- package/dist/components/MkTable.d.ts +8 -1
- package/dist/components/MkTable.d.ts.map +1 -1
- package/dist/components/MkTable.js +28 -2
- package/dist/components/MkTable.js.map +1 -1
- package/dist/hooks/useApi.d.ts +21 -5
- package/dist/hooks/useApi.d.ts.map +1 -1
- package/dist/hooks/useApi.js +83 -63
- package/dist/hooks/useApi.js.map +1 -1
- package/dist/hooks/useMkInfiniteList.d.ts +1 -1
- package/dist/hooks/useMkList.d.ts +8 -12
- package/dist/hooks/useMkList.d.ts.map +1 -1
- package/dist/hooks/useMkList.js +23 -9
- package/dist/hooks/useMkList.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/eslint-plugin-mk/__tests__/no-cross-module-import-dynamic.test.js +89 -0
- package/eslint-plugin-mk/rules/no-cross-module-import.js +16 -0
- package/package.json +7 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,a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cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AAExC,QAAQ;AACR,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AAEnC,qEAAqE;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAW/C,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GAExB,MAAM,2BAA2B,CAAC;AAEnC,QAAQ;AACR,cAAc,gBAAgB,CAAC;AAE/B,4EAA4E;AAC5E,uEAAuE;AACvE,qEAAqE;AACrE,2EAA2E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vitest-environment node
|
|
3
|
+
*
|
|
4
|
+
* Dynamic import() coverage for the MME enforcer (R-MK-001).
|
|
5
|
+
* Blocked in rc12 because the original rule only handled
|
|
6
|
+
* `ImportDeclaration` and `ExportNamedDeclaration`/`ExportAllDeclaration`,
|
|
7
|
+
* letting `await import('@/modules/admin/...')` bypass the boundary check.
|
|
8
|
+
*
|
|
9
|
+
* Companion to `no-cross-module-import.test.js`. We keep this as a
|
|
10
|
+
* separate file so the failure mode ("dynamic imports leak") is
|
|
11
|
+
* obvious from the file name at PR review time.
|
|
12
|
+
*/
|
|
13
|
+
import { describe, it, expect } from 'vitest';
|
|
14
|
+
import { RuleTester } from 'eslint';
|
|
15
|
+
import rule from '../rules/no-cross-module-import.js';
|
|
16
|
+
|
|
17
|
+
const ruleTester = new RuleTester({
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2022,
|
|
20
|
+
sourceType: 'module',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('no-cross-module-import — dynamic import()', () => {
|
|
25
|
+
ruleTester.run('no-cross-module-import (dynamic)', rule, {
|
|
26
|
+
valid: [
|
|
27
|
+
// Dynamic import of same module's deep path — OK
|
|
28
|
+
{
|
|
29
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
30
|
+
code: "const m = await import('@/modules/payments/components/PaymentForm');",
|
|
31
|
+
},
|
|
32
|
+
// Dynamic import of another module's public index — OK
|
|
33
|
+
{
|
|
34
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
35
|
+
code: "const m = await import('@/modules/admin');",
|
|
36
|
+
},
|
|
37
|
+
// Dynamic import outside any module — OK
|
|
38
|
+
{
|
|
39
|
+
filename: '/app/src/app/admin/page.tsx',
|
|
40
|
+
code: "const m = await import('@/modules/admin/components/AdminForm');",
|
|
41
|
+
},
|
|
42
|
+
// Dynamic import with non-literal expression — silently skipped
|
|
43
|
+
// (cannot be analyzed statically). This is an accepted gap, not a bug.
|
|
44
|
+
{
|
|
45
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
46
|
+
code: "const m = await import(someDynamicPath);",
|
|
47
|
+
},
|
|
48
|
+
// Dynamic import in test file pointing cross-module — OK (tests excluded)
|
|
49
|
+
{
|
|
50
|
+
filename: '/app/src/modules/payments/__tests__/usePayment.test.ts',
|
|
51
|
+
code: "const m = await import('@/modules/admin/components/AdminForm');",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
|
|
55
|
+
invalid: [
|
|
56
|
+
// Dynamic import cross-module deep path — should fail
|
|
57
|
+
{
|
|
58
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
59
|
+
code: "const m = await import('@/modules/admin/components/AdminForm');",
|
|
60
|
+
errors: [{ messageId: 'forbidden' }],
|
|
61
|
+
},
|
|
62
|
+
// Dynamic import cross-module via relative path — should fail
|
|
63
|
+
{
|
|
64
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
65
|
+
code: "const m = await import('../../admin/components/AdminForm');",
|
|
66
|
+
errors: [{ messageId: 'forbidden' }],
|
|
67
|
+
},
|
|
68
|
+
// Synchronous dynamic import (top-level await) cross-module — should fail
|
|
69
|
+
{
|
|
70
|
+
filename: '/app/src/modules/payments/hooks/usePayment.ts',
|
|
71
|
+
code: "const m = import('@/modules/admin/components/AdminForm');",
|
|
72
|
+
errors: [{ messageId: 'forbidden' }],
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('registers the dynamic-import visitor', () => {
|
|
78
|
+
// Sanity check: the rule's create() returns an ImportExpression
|
|
79
|
+
// visitor. If a future refactor drops it, this test fails loudly
|
|
80
|
+
// instead of silently letting dynamic imports bypass the rule.
|
|
81
|
+
const sandboxFilename = '/app/src/modules/payments/hooks/usePayment.ts';
|
|
82
|
+
const context = {
|
|
83
|
+
getFilename: () => sandboxFilename,
|
|
84
|
+
report: () => {},
|
|
85
|
+
};
|
|
86
|
+
const visitors = rule.create(context);
|
|
87
|
+
expect(typeof visitors.ImportExpression).toBe('function');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* inside another module. Only `@/modules/{X}` (the index/public API)
|
|
6
6
|
* is allowed.
|
|
7
7
|
*
|
|
8
|
+
* Covers both static `import ... from '...'` and dynamic
|
|
9
|
+
* `import('...')` (await import() for code splitting) so that
|
|
10
|
+
* R-MK-001 cannot be bypassed via dynamic imports.
|
|
11
|
+
*
|
|
8
12
|
* Scenarios:
|
|
9
13
|
* Given file src/modules/payments/hooks/usePayment.ts
|
|
10
14
|
* When it imports '@/modules/admin/components/AdminForm'
|
|
@@ -14,6 +18,9 @@
|
|
|
14
18
|
* Given the same file imports '@/modules/admin'
|
|
15
19
|
* Then the lint passes.
|
|
16
20
|
*
|
|
21
|
+
* Given the same file does `await import('@/modules/admin/components/AdminForm')`
|
|
22
|
+
* Then the lint also fails (dynamic imports are caught).
|
|
23
|
+
*
|
|
17
24
|
* Given a file OUTSIDE any module (e.g. src/app/admin/page.tsx)
|
|
18
25
|
* When it imports '@/modules/admin/...'
|
|
19
26
|
* Then the lint passes — the app is the consumer of the public API.
|
|
@@ -58,6 +65,12 @@ export default {
|
|
|
58
65
|
const sourceModule = moduleMatch[1];
|
|
59
66
|
|
|
60
67
|
function checkImport(node) {
|
|
68
|
+
// Both ImportDeclaration and ImportExpression (dynamic import())
|
|
69
|
+
// carry the literal source string at `node.source.value` when the
|
|
70
|
+
// argument is a string literal. For dynamic imports with a
|
|
71
|
+
// non-literal expression (e.g. `import(someVar)`), this is
|
|
72
|
+
// `undefined` and we skip the check — those cases need static
|
|
73
|
+
// analysis beyond ESLint.
|
|
61
74
|
const importPath = node.source?.value;
|
|
62
75
|
if (typeof importPath !== 'string') return;
|
|
63
76
|
|
|
@@ -92,6 +105,9 @@ export default {
|
|
|
92
105
|
|
|
93
106
|
return {
|
|
94
107
|
ImportDeclaration: checkImport,
|
|
108
|
+
// Catches `await import('...')` and `import('...')` so R-MK-001
|
|
109
|
+
// cannot be bypassed via dynamic imports for code splitting.
|
|
110
|
+
ImportExpression: checkImport,
|
|
95
111
|
// Also catch `export ... from '...'` re-exports.
|
|
96
112
|
ExportNamedDeclaration: checkImport,
|
|
97
113
|
ExportAllDeclaration: checkImport,
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makroz/web",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6-rc14",
|
|
4
4
|
"description": "React UI components and hooks for MK-Director web applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mk-update": "./bin/mk-update.js"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./dist/index.d.ts",
|
|
@@ -17,7 +20,8 @@
|
|
|
17
20
|
},
|
|
18
21
|
"files": [
|
|
19
22
|
"dist",
|
|
20
|
-
"eslint-plugin-mk"
|
|
23
|
+
"eslint-plugin-mk",
|
|
24
|
+
"bin"
|
|
21
25
|
],
|
|
22
26
|
"publishConfig": {
|
|
23
27
|
"access": "public"
|
|
@@ -29,7 +33,7 @@
|
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
31
35
|
"@tanstack/react-query": "^5.62.0",
|
|
32
|
-
"@makroz/core": "1.1.
|
|
36
|
+
"@makroz/core": "1.1.6-rc14"
|
|
33
37
|
},
|
|
34
38
|
"peerDependencies": {
|
|
35
39
|
"next": "^16.0.0",
|