slicejs-web-framework 3.4.4 → 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 (101) hide show
  1. package/Slice/Components/Structural/Controller/Controller.js +135 -0
  2. package/Slice/Components/Structural/EventManager/EventManager.js +289 -4
  3. package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +368 -30
  4. package/Slice/Components/Structural/LeakInspector/LeakInspector.js +296 -0
  5. package/Slice/Slice.js +14 -1
  6. package/Slice/tests/event-emitters.test.js +79 -0
  7. package/Slice/tests/event-registry.test.js +141 -0
  8. package/Slice/tests/leak-orphans.test.js +131 -0
  9. package/api/index.js +35 -8
  10. package/package.json +1 -1
  11. package/sliceConfig.schema.json +10 -1
  12. package/src/sliceConfig.json +5 -1
  13. package/types/index.d.ts +12 -0
  14. package/slicejs-cli/.github/workflows/ci.yml +0 -43
  15. package/slicejs-cli/LICENSE +0 -21
  16. package/slicejs-cli/assets/Slice.js-logo.png +0 -0
  17. package/slicejs-cli/client.js +0 -740
  18. package/slicejs-cli/commands/Print.js +0 -164
  19. package/slicejs-cli/commands/Validations.js +0 -92
  20. package/slicejs-cli/commands/build/build.js +0 -40
  21. package/slicejs-cli/commands/buildProduction/buildProduction.js +0 -577
  22. package/slicejs-cli/commands/bundle/bundle.js +0 -236
  23. package/slicejs-cli/commands/createComponent/VisualComponentTemplate.js +0 -55
  24. package/slicejs-cli/commands/createComponent/createComponent.js +0 -128
  25. package/slicejs-cli/commands/deleteComponent/deleteComponent.js +0 -81
  26. package/slicejs-cli/commands/doctor/doctor.js +0 -516
  27. package/slicejs-cli/commands/getComponent/getComponent.js +0 -695
  28. package/slicejs-cli/commands/init/init.js +0 -473
  29. package/slicejs-cli/commands/listComponents/listComponents.js +0 -172
  30. package/slicejs-cli/commands/startServer/startServer.js +0 -240
  31. package/slicejs-cli/commands/startServer/watchServer.js +0 -66
  32. package/slicejs-cli/commands/types/types.js +0 -583
  33. package/slicejs-cli/commands/utils/LocalCliDelegation.js +0 -53
  34. package/slicejs-cli/commands/utils/PackageManager.js +0 -148
  35. package/slicejs-cli/commands/utils/PathHelper.js +0 -75
  36. package/slicejs-cli/commands/utils/VersionChecker.js +0 -169
  37. package/slicejs-cli/commands/utils/bundling/BundleGenerator.js +0 -2525
  38. package/slicejs-cli/commands/utils/bundling/DependencyAnalyzer.js +0 -933
  39. package/slicejs-cli/commands/utils/loadConfig.js +0 -31
  40. package/slicejs-cli/commands/utils/sliceScripts.js +0 -48
  41. package/slicejs-cli/commands/utils/updateManager.js +0 -471
  42. package/slicejs-cli/package.json +0 -71
  43. package/slicejs-cli/playwright.config.js +0 -51
  44. package/slicejs-cli/pnpm-lock.yaml +0 -1629
  45. package/slicejs-cli/tests/build-command-integration.test.js +0 -87
  46. package/slicejs-cli/tests/build-mangling-e2e.test.js +0 -290
  47. package/slicejs-cli/tests/build-production-e2e.test.js +0 -140
  48. package/slicejs-cli/tests/builder-edge-cases.test.js +0 -322
  49. package/slicejs-cli/tests/bundle-generate-e2e.test.js +0 -115
  50. package/slicejs-cli/tests/bundle-generator.test.js +0 -691
  51. package/slicejs-cli/tests/bundle-v2-register-output.test.js +0 -470
  52. package/slicejs-cli/tests/bundling-dependency-edges.test.js +0 -127
  53. package/slicejs-cli/tests/bundling-imports-unit.test.js +0 -267
  54. package/slicejs-cli/tests/client-launcher-contract.test.js +0 -211
  55. package/slicejs-cli/tests/commands-component-crud.test.js +0 -128
  56. package/slicejs-cli/tests/commands-doctor.test.js +0 -152
  57. package/slicejs-cli/tests/commands-version-checker.test.js +0 -37
  58. package/slicejs-cli/tests/component-registry-parse.test.js +0 -34
  59. package/slicejs-cli/tests/dependency-analyzer.test.js +0 -24
  60. package/slicejs-cli/tests/e2e/bundles.spec.js +0 -91
  61. package/slicejs-cli/tests/e2e/dependency-scenarios.spec.js +0 -56
  62. package/slicejs-cli/tests/e2e/fixtures/components/Service/FetchManager/FetchManager.js +0 -136
  63. package/slicejs-cli/tests/e2e/fixtures/components/Service/IndexedDbManager/IndexedDbManager.js +0 -149
  64. package/slicejs-cli/tests/e2e/fixtures/components/Service/LocalStorageManager/LocalStorageManager.js +0 -45
  65. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Button/Button.css +0 -106
  66. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Button/Button.html +0 -5
  67. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Button/Button.js +0 -158
  68. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Link/Link.js +0 -33
  69. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Loading/Loading.css +0 -56
  70. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Loading/Loading.html +0 -83
  71. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Loading/Loading.js +0 -164
  72. package/slicejs-cli/tests/e2e/fixtures/components/Visual/MultiRoute/MultiRoute.js +0 -167
  73. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Navbar/Navbar.css +0 -116
  74. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Navbar/Navbar.html +0 -44
  75. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Navbar/Navbar.js +0 -180
  76. package/slicejs-cli/tests/e2e/fixtures/components/Visual/NotFound/NotFound.js +0 -20
  77. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Route/Route.js +0 -181
  78. package/slicejs-cli/tests/e2e/fixtures/components/registry.json +0 -12
  79. package/slicejs-cli/tests/e2e/fixtures/vendor-components.mjs +0 -65
  80. package/slicejs-cli/tests/e2e/navigation.spec.js +0 -44
  81. package/slicejs-cli/tests/e2e/render.spec.js +0 -34
  82. package/slicejs-cli/tests/e2e/serve.mjs +0 -264
  83. package/slicejs-cli/tests/e2e/shared-deps.spec.js +0 -61
  84. package/slicejs-cli/tests/e2e/unminified.spec.js +0 -33
  85. package/slicejs-cli/tests/e2e-serve.test.js +0 -148
  86. package/slicejs-cli/tests/fixtures/components.js +0 -8
  87. package/slicejs-cli/tests/fixtures/sliceConfig.json +0 -74
  88. package/slicejs-cli/tests/getcomponent.test.js +0 -435
  89. package/slicejs-cli/tests/helpers/setup.js +0 -102
  90. package/slicejs-cli/tests/init-command-contract.test.js +0 -101
  91. package/slicejs-cli/tests/init-e2e.test.js +0 -82
  92. package/slicejs-cli/tests/init-project-isolation.test.js +0 -98
  93. package/slicejs-cli/tests/local-cli-delegation.test.js +0 -81
  94. package/slicejs-cli/tests/package-manager.test.js +0 -127
  95. package/slicejs-cli/tests/path-helper.test.js +0 -206
  96. package/slicejs-cli/tests/perf-budget.test.js +0 -84
  97. package/slicejs-cli/tests/postinstall-command.test.js +0 -103
  98. package/slicejs-cli/tests/property-mangling-regression.test.js +0 -182
  99. package/slicejs-cli/tests/types-breakage.test.js +0 -491
  100. package/slicejs-cli/tests/types-generator-errors.test.js +0 -361
  101. package/slicejs-cli/tests/types-generator.test.js +0 -348
@@ -1,148 +0,0 @@
1
- // commands/utils/PackageManager.js
2
- //
3
- // Package manager detection and command building (pnpm / npm).
4
- // Resolution priority for an existing project:
5
- // 1. "packageManager" field in the project package.json (corepack convention)
6
- // 2. Lockfile present at the project root
7
- // 3. npm_config_user_agent (set when the CLI runs via `npx` / `pnpm dlx` / a PM script)
8
- // 4. The only PM binary available on PATH (if exactly one)
9
- // When everything is ambiguous, detectPackageManager() returns null so callers
10
- // can prompt the user (interactive init) or fall back to pnpm (non-interactive).
11
-
12
- import fs from 'fs-extra'
13
- import path from 'path'
14
- import { spawnSync } from 'node:child_process'
15
-
16
- export const SUPPORTED_PACKAGE_MANAGERS = ['pnpm', 'npm']
17
-
18
- const LOCKFILES = {
19
- 'pnpm-lock.yaml': 'pnpm',
20
- 'package-lock.json': 'npm'
21
- }
22
-
23
- export function parseUserAgent(userAgent = process.env.npm_config_user_agent) {
24
- if (!userAgent) return null
25
- const match = userAgent.match(/^(npm|pnpm)\/(\S+)/)
26
- if (!match) return null
27
- return { name: match[1], version: match[2], source: 'user-agent' }
28
- }
29
-
30
- export function fromPackageManagerField(projectRoot) {
31
- try {
32
- const pkgPath = path.join(projectRoot, 'package.json')
33
- if (!fs.pathExistsSync(pkgPath)) return null
34
- const pkg = fs.readJsonSync(pkgPath)
35
- if (typeof pkg.packageManager !== 'string') return null
36
- const match = pkg.packageManager.match(/^(npm|pnpm)@(\S+)/)
37
- if (!match) return null
38
- return { name: match[1], version: match[2], source: 'package-manager-field' }
39
- } catch {
40
- return null
41
- }
42
- }
43
-
44
- export function fromLockfile(projectRoot) {
45
- for (const [lockfile, name] of Object.entries(LOCKFILES)) {
46
- if (fs.pathExistsSync(path.join(projectRoot, lockfile))) {
47
- return { name, version: null, source: `lockfile (${lockfile})` }
48
- }
49
- }
50
- return null
51
- }
52
-
53
- function runPmBinary(name, args) {
54
- // On Windows the PM entry points are .cmd shims, which require shell resolution.
55
- const isWindows = process.platform === 'win32'
56
- return spawnSync(name, args, {
57
- stdio: ['ignore', 'pipe', 'ignore'],
58
- shell: isWindows,
59
- encoding: 'utf-8'
60
- })
61
- }
62
-
63
- export function isPackageManagerAvailable(name) {
64
- try {
65
- const result = runPmBinary(name, ['--version'])
66
- return result.status === 0
67
- } catch {
68
- return false
69
- }
70
- }
71
-
72
- export function getPackageManagerVersion(name) {
73
- try {
74
- const result = runPmBinary(name, ['--version'])
75
- if (result.status !== 0) return null
76
- return (result.stdout || '').toString().trim() || null
77
- } catch {
78
- return null
79
- }
80
- }
81
-
82
- export function getAvailablePackageManagers() {
83
- return SUPPORTED_PACKAGE_MANAGERS.filter(isPackageManagerAvailable)
84
- }
85
-
86
- /**
87
- * Detect the package manager for a project.
88
- * Returns { name, version, source } or null when genuinely ambiguous.
89
- */
90
- export function detectPackageManager(projectRoot, { userAgent = process.env.npm_config_user_agent } = {}) {
91
- if (projectRoot) {
92
- const fromField = fromPackageManagerField(projectRoot)
93
- if (fromField) return fromField
94
-
95
- const fromLock = fromLockfile(projectRoot)
96
- if (fromLock) return fromLock
97
- }
98
-
99
- const fromUa = parseUserAgent(userAgent)
100
- if (fromUa) return fromUa
101
-
102
- const available = getAvailablePackageManagers()
103
- if (available.length === 1) {
104
- return { name: available[0], version: null, source: 'only available binary' }
105
- }
106
-
107
- return null
108
- }
109
-
110
- /**
111
- * Non-interactive resolution: detection first, then pnpm if available,
112
- * then whatever binary exists. Never returns null so update/doctor flows
113
- * always have a usable PM name (commands fail later with a clear error
114
- * if no PM is actually installed).
115
- */
116
- export function resolvePackageManager(projectRoot, options = {}) {
117
- const detected = detectPackageManager(projectRoot, options)
118
- if (detected) return detected
119
-
120
- const available = getAvailablePackageManagers()
121
- if (available.includes('pnpm')) return { name: 'pnpm', version: null, source: 'fallback' }
122
- if (available.includes('npm')) return { name: 'npm', version: null, source: 'fallback' }
123
- if (available.length > 0) return { name: available[0], version: null, source: 'fallback' }
124
- return { name: 'pnpm', version: null, source: 'fallback (none detected)' }
125
- }
126
-
127
- export function installCommand(pmName, packages, { dev = false, global: isGlobal = false } = {}) {
128
- const pkgs = Array.isArray(packages) ? packages.join(' ') : packages
129
- const flags = [isGlobal ? '-g' : '', dev ? '-D' : ''].filter(Boolean).join(' ')
130
- const flagSuffix = flags ? ` ${flags}` : ''
131
- if (pmName === 'pnpm') {
132
- return `${pmName} add${flagSuffix} ${pkgs}`
133
- }
134
- return `npm install${flagSuffix} ${pkgs}`
135
- }
136
-
137
- export function uninstallCommand(pmName, packages, { global: isGlobal = false } = {}) {
138
- const pkgs = Array.isArray(packages) ? packages.join(' ') : packages
139
- const flagSuffix = isGlobal ? ' -g' : ''
140
- if (pmName === 'pnpm') {
141
- return `${pmName} remove${flagSuffix} ${pkgs}`
142
- }
143
- return `npm uninstall${flagSuffix} ${pkgs}`
144
- }
145
-
146
- export function runScriptCommand(pmName, script) {
147
- return `${pmName} run ${script}`
148
- }
@@ -1,75 +0,0 @@
1
- import path from 'path'
2
- import fs from 'fs-extra'
3
- import { fileURLToPath } from 'url'
4
-
5
- const sanitize = (s) => (s || '').replace(/^[/\\]+/, '')
6
- const dirOf = (url) => path.dirname(fileURLToPath(url))
7
-
8
- function candidates(moduleUrl) {
9
- const dir = dirOf(moduleUrl)
10
- return [
11
- path.join(dir, '../../'),
12
- path.join(dir, '../../../../')
13
- ]
14
- }
15
-
16
- function resolveProjectRoot(moduleUrl) {
17
- const initCwd = process.env.INIT_CWD
18
- if (initCwd && fs.pathExistsSync(initCwd)) {
19
- return initCwd
20
- }
21
-
22
- const cwd = process.cwd()
23
- if (cwd && fs.pathExistsSync(cwd)) {
24
- return cwd
25
- }
26
-
27
- const dirs = candidates(moduleUrl)
28
- for (const root of dirs) {
29
- const hasSrc = fs.pathExistsSync(path.join(root, 'src'))
30
- const hasApi = fs.pathExistsSync(path.join(root, 'api'))
31
- if (hasSrc || hasApi) return root
32
- }
33
- return dirs[1]
34
- }
35
-
36
- function joinProject(moduleUrl, ...segments) {
37
- const root = resolveProjectRoot(moduleUrl)
38
- const clean = segments.map(sanitize)
39
- return path.join(root, ...clean)
40
- }
41
-
42
- export function getProjectRoot(moduleUrl) {
43
- return resolveProjectRoot(moduleUrl)
44
- }
45
-
46
- export function getPath(moduleUrl, folder, ...segments) {
47
- return joinProject(moduleUrl, folder, ...segments)
48
- }
49
-
50
- export function getSrcPath(moduleUrl, ...segments) {
51
- return joinProject(moduleUrl, 'src', ...segments)
52
- }
53
-
54
- export function getApiPath(moduleUrl, ...segments) {
55
- return joinProject(moduleUrl, 'api', ...segments)
56
- }
57
-
58
- export function getDistPath(moduleUrl, ...segments) {
59
- return joinProject(moduleUrl, 'dist', ...segments)
60
- }
61
-
62
- export function getConfigPath(moduleUrl, root) {
63
- if (root) return path.join(root, 'src', 'sliceConfig.json')
64
- return joinProject(moduleUrl, 'src', 'sliceConfig.json')
65
- }
66
-
67
- export function getComponentsJsPath(moduleUrl, root) {
68
- if (root) return path.join(root, 'src', 'Components', 'components.js')
69
- return joinProject(moduleUrl, 'src', 'Components', 'components.js')
70
- }
71
-
72
- export function joinRoot(root, ...segments) {
73
- const clean = segments.map(sanitize)
74
- return path.join(root, ...clean)
75
- }
@@ -1,169 +0,0 @@
1
- // commands/utils/VersionChecker.js
2
-
3
- import fs from "fs-extra";
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
- import Print from "../Print.js";
7
- import { getProjectRoot, getPath } from "../utils/PathHelper.js";
8
- import { resolvePackageManager } from "../utils/PackageManager.js";
9
-
10
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
-
12
- class VersionChecker {
13
- constructor() {
14
- this.currentCliVersion = null;
15
- this.currentFrameworkVersion = null;
16
- this.latestCliVersion = null;
17
- this.latestFrameworkVersion = null;
18
- }
19
-
20
- async getCurrentVersions() {
21
- try {
22
- // Get CLI version
23
- const cliPackagePath = path.join(__dirname, '../../package.json');
24
- const cliPackage = await fs.readJson(cliPackagePath);
25
- this.currentCliVersion = cliPackage.version;
26
-
27
- // Get Framework version from project node_modules
28
- const projectRoot = getProjectRoot(import.meta.url);
29
- const frameworkPackagePath = getPath(import.meta.url, 'node_modules', 'slicejs-web-framework', 'package.json');
30
- if (await fs.pathExists(frameworkPackagePath)) {
31
- const frameworkPackage = await fs.readJson(frameworkPackagePath);
32
- this.currentFrameworkVersion = frameworkPackage.version;
33
- }
34
-
35
- // Get Project's CLI version
36
- const projectPackagePath = getPath(import.meta.url, 'package.json');
37
- if (await fs.pathExists(projectPackagePath)) {
38
- const projectPackage = await fs.readJson(projectPackagePath);
39
- if (projectPackage.dependencies && projectPackage.dependencies['slicejs-cli']) {
40
- // This could be different from the currently running CLI version
41
- }
42
- }
43
-
44
- return {
45
- cli: this.currentCliVersion,
46
- framework: this.currentFrameworkVersion
47
- };
48
- } catch (error) {
49
- return null;
50
- }
51
- }
52
-
53
- async getLatestVersions() {
54
- try {
55
- // Check CLI version
56
- const cliResponse = await fetch('https://registry.npmjs.org/slicejs-cli/latest', {
57
- headers: { 'Accept': 'application/json' }
58
- });
59
-
60
- if (cliResponse.ok) {
61
- const cliData = await cliResponse.json();
62
- this.latestCliVersion = cliData.version;
63
- }
64
-
65
- // Check Framework version
66
- const frameworkResponse = await fetch('https://registry.npmjs.org/slicejs-web-framework/latest', {
67
- headers: { 'Accept': 'application/json' }
68
- });
69
-
70
- if (frameworkResponse.ok) {
71
- const frameworkData = await frameworkResponse.json();
72
- this.latestFrameworkVersion = frameworkData.version;
73
- }
74
-
75
- return {
76
- cli: this.latestCliVersion,
77
- framework: this.latestFrameworkVersion
78
- };
79
- } catch (error) {
80
- // Silent fail - don't interrupt commands for version check failures
81
- return null;
82
- }
83
- }
84
-
85
- compareVersions(current, latest) {
86
- if (!current || !latest) return null;
87
-
88
- const currentParts = current.split('.').map(Number);
89
- const latestParts = latest.split('.').map(Number);
90
-
91
- for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
92
- const currentPart = currentParts[i] || 0;
93
- const latestPart = latestParts[i] || 0;
94
-
95
- if (latestPart > currentPart) return 'outdated';
96
- if (currentPart > latestPart) return 'newer';
97
- }
98
-
99
- return 'current';
100
- }
101
-
102
- async checkForUpdates(silent = false) {
103
- try {
104
- const current = await this.getCurrentVersions();
105
- if (!current) return;
106
-
107
- const latest = await this.getLatestVersions();
108
- if (!latest) return;
109
-
110
- const cliStatus = this.compareVersions(current.cli, latest.cli);
111
- const frameworkStatus = this.compareVersions(current.framework, latest.framework);
112
-
113
- if (!silent && (cliStatus === 'outdated' || frameworkStatus === 'outdated')) {
114
- const pm = resolvePackageManager(getProjectRoot(import.meta.url)).name;
115
- console.log(''); // Line break
116
- Print.warning('šŸ“¦ Available Updates:');
117
-
118
- if (cliStatus === 'outdated') {
119
- console.log(` šŸ”§ CLI: ${current.cli} → ${latest.cli}`);
120
- console.log(` ${pm} update slicejs-cli`);
121
- }
122
-
123
- if (frameworkStatus === 'outdated') {
124
- console.log(` ⚔ Framework: ${current.framework} → ${latest.framework}`);
125
- console.log(` ${pm} update slicejs-web-framework`);
126
- }
127
-
128
- console.log(' šŸ“š Changelog: https://github.com/VKneider/slice.js/releases');
129
- console.log(''); // Line break
130
- }
131
-
132
- return {
133
- cli: { current: current.cli, latest: latest.cli, status: cliStatus },
134
- framework: { current: current.framework, latest: latest.framework, status: frameworkStatus }
135
- };
136
-
137
- } catch (error) {
138
- // Silent fail - don't interrupt commands
139
- return null;
140
- }
141
- }
142
-
143
- async showVersionInfo() {
144
- const current = await this.getCurrentVersions();
145
- const latest = await this.getLatestVersions();
146
-
147
- console.log('\nšŸ“‹ Version Information:');
148
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
149
-
150
- if (current?.cli) {
151
- const cliStatus = this.compareVersions(current.cli, latest?.cli);
152
- const statusIcon = cliStatus === 'current' ? 'āœ…' : cliStatus === 'outdated' ? 'šŸ”„' : 'šŸ†•';
153
- console.log(`${statusIcon} CLI: v${current.cli}${latest?.cli && latest.cli !== current.cli ? ` (latest: v${latest.cli})` : ''}`);
154
- }
155
-
156
- if (current?.framework) {
157
- const frameworkStatus = this.compareVersions(current.framework, latest?.framework);
158
- const statusIcon = frameworkStatus === 'current' ? 'āœ…' : frameworkStatus === 'outdated' ? 'šŸ”„' : 'šŸ†•';
159
- console.log(`${statusIcon} Framework: v${current.framework}${latest?.framework && latest.framework !== current.framework ? ` (latest: v${latest.framework})` : ''}`);
160
- }
161
-
162
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
163
- }
164
- }
165
-
166
- // Singleton instance
167
- const versionChecker = new VersionChecker();
168
-
169
- export default versionChecker;