solidstep 0.1.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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/client.d.ts +4 -0
  4. package/client.d.ts.map +1 -0
  5. package/client.js +91 -0
  6. package/index.d.ts +11 -0
  7. package/index.d.ts.map +1 -0
  8. package/index.js +97 -0
  9. package/package.json +58 -0
  10. package/server.d.ts +3 -0
  11. package/server.d.ts.map +1 -0
  12. package/server.js +666 -0
  13. package/utils/cache.d.ts +5 -0
  14. package/utils/cache.d.ts.map +1 -0
  15. package/utils/cache.js +97 -0
  16. package/utils/cookies.d.ts +5 -0
  17. package/utils/cookies.d.ts.map +1 -0
  18. package/utils/cookies.js +13 -0
  19. package/utils/cors.d.ts +14 -0
  20. package/utils/cors.d.ts.map +1 -0
  21. package/utils/cors.js +15 -0
  22. package/utils/csp.d.ts +38 -0
  23. package/utils/csp.d.ts.map +1 -0
  24. package/utils/csp.js +165 -0
  25. package/utils/csrf.d.ts +5 -0
  26. package/utils/csrf.d.ts.map +1 -0
  27. package/utils/csrf.js +46 -0
  28. package/utils/error-handler.d.ts +37 -0
  29. package/utils/error-handler.d.ts.map +1 -0
  30. package/utils/error-handler.js +40 -0
  31. package/utils/fetch.client.d.ts +23 -0
  32. package/utils/fetch.client.d.ts.map +1 -0
  33. package/utils/fetch.client.js +55 -0
  34. package/utils/fetch.server.d.ts +22 -0
  35. package/utils/fetch.server.d.ts.map +1 -0
  36. package/utils/fetch.server.js +54 -0
  37. package/utils/hooks/action-state.d.ts +3 -0
  38. package/utils/hooks/action-state.d.ts.map +1 -0
  39. package/utils/hooks/action-state.js +13 -0
  40. package/utils/loader.d.ts +18 -0
  41. package/utils/loader.d.ts.map +1 -0
  42. package/utils/loader.js +23 -0
  43. package/utils/redirect.d.ts +5 -0
  44. package/utils/redirect.d.ts.map +1 -0
  45. package/utils/redirect.js +14 -0
  46. package/utils/router.d.ts +104 -0
  47. package/utils/router.d.ts.map +1 -0
  48. package/utils/router.js +258 -0
  49. package/utils/server-action.client.d.ts +2 -0
  50. package/utils/server-action.client.d.ts.map +1 -0
  51. package/utils/server-action.client.js +200 -0
  52. package/utils/server-action.server.d.ts +5 -0
  53. package/utils/server-action.server.d.ts.map +1 -0
  54. package/utils/server-action.server.js +264 -0
  55. package/utils/server-only.d.ts +2 -0
  56. package/utils/server-only.d.ts.map +1 -0
  57. package/utils/server-only.js +4 -0
  58. package/utils/types.d.ts +8 -0
  59. package/utils/types.d.ts.map +1 -0
  60. package/utils/types.js +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hamza Varvani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @varlabs/create-solidstep
2
+ Next Step SolidJS CLI for building web applications.
3
+
4
+ ## Getting Started
5
+
6
+ To get started with a new SolidJS project using the Next Step CLI, run the following command:
7
+
8
+ ```bash
9
+ npx @varlabs/create-solidstep@latest my-app
10
+ ```
11
+
12
+ or
13
+
14
+ ```bash
15
+ pnpm dlx @varlabs/create-solidstep@latest my-app
16
+ ```
17
+
18
+ Replace `my-app` with the name of your project or if you don't specify a name, it will create a project in the current directory.
package/client.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import 'vinxi/client';
2
+ export declare const main: (modulePath: string, routeParams?: Record<string, string>, searchParams?: Record<string, string>, loaderDataManifest?: Record<string, any>) => Promise<void>;
3
+ export default main;
4
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAC;AAYtB,eAAO,MAAM,IAAI,GACb,YAAY,MAAM,EAClB,cAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACxC,eAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACzC,qBAAoB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,kBAsF/C,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/client.js ADDED
@@ -0,0 +1,91 @@
1
+ import { hydrate } from 'solid-js/web';
2
+ import 'vinxi/client';
3
+ import fileRoutes from 'vinxi/routes';
4
+ import { getManifest } from 'vinxi/manifest';
5
+ const importModule = async (routeModule) => {
6
+ const manifest = getManifest('client');
7
+ if (import.meta.env.DEV) {
8
+ return await manifest.inputs[routeModule.src].import();
9
+ }
10
+ return await routeModule.import();
11
+ };
12
+ export const main = async (modulePath, routeParams = {}, searchParams = {}, loaderDataManifest = {}) => {
13
+ // find the route that matches the path
14
+ const pageModule = fileRoutes.find((route) => route.path === modulePath);
15
+ if (!pageModule) {
16
+ console.error(`No route found for path: ${modulePath}`);
17
+ return;
18
+ }
19
+ const pageLoaderData = loaderDataManifest[modulePath];
20
+ const segments = modulePath.split('/').slice(2);
21
+ if (segments.at(0)) {
22
+ segments.unshift('');
23
+ }
24
+ const layouts = [];
25
+ const layoutLoaderData = [];
26
+ const groups = {};
27
+ for (let i = 0; i < segments.length; i++) {
28
+ const path = `/${segments.slice(1, segments.length - i).join('/')}`;
29
+ const loaderData = loaderDataManifest[`/layout${path}`];
30
+ const layoutModule = fileRoutes.find((route) => {
31
+ const routePath = `/${route.path.split('/').slice(2).join('/')}`;
32
+ return routePath === path && route.type === 'layout';
33
+ });
34
+ if (layoutModule) {
35
+ layouts.unshift(layoutModule);
36
+ }
37
+ if (loaderData) {
38
+ layoutLoaderData.unshift(loaderData);
39
+ }
40
+ }
41
+ const groupModules = fileRoutes.filter((route) => {
42
+ const parentPath = route.parent || '';
43
+ return parentPath === segments.join('/') && route.type === 'group';
44
+ });
45
+ if (groupModules && groupModules.length > 0) {
46
+ for (const groupModule of groupModules) {
47
+ const groupName = groupModule.path.split('/').at(-1)?.replace('@', '');
48
+ if (!groupName)
49
+ continue;
50
+ groups[groupName] = groupModule;
51
+ }
52
+ }
53
+ const compose = layouts.reduceRight((children, layout, index) => async () => {
54
+ const { default: layoutModule } = await importModule(layout.$component);
55
+ const loaderData = layoutLoaderData[index] || {};
56
+ const slots = {};
57
+ const slotPromises = [children()];
58
+ if (index === layouts.length - 1) {
59
+ // last layout, we can render slots
60
+ for (const [groupName, group] of Object.entries(groups)) {
61
+ slotPromises.push((async () => {
62
+ const { default: groupPage } = await importModule(group.$component);
63
+ const groupLoaderData = loaderDataManifest[group.path] || {};
64
+ slots[groupName] = () => groupPage({
65
+ routeParams,
66
+ searchParams,
67
+ loaderData: groupLoaderData,
68
+ });
69
+ })());
70
+ }
71
+ }
72
+ const [childrenRendered] = await Promise.all(slotPromises);
73
+ return () => layoutModule({
74
+ children: childrenRendered,
75
+ routeParams,
76
+ searchParams,
77
+ slots: slots,
78
+ loaderData,
79
+ });
80
+ }, async () => {
81
+ const { default: page } = await importModule(pageModule.$component);
82
+ return () => page({
83
+ routeParams,
84
+ searchParams,
85
+ loaderData: pageLoaderData || {},
86
+ });
87
+ });
88
+ const composed = await compose();
89
+ hydrate(() => composed(), document);
90
+ };
91
+ export default main;
package/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { AppOptions } from 'vinxi';
2
+ type Config = {
3
+ server?: Omit<AppOptions['server'], 'experimental'>;
4
+ plugins?: {
5
+ type: 'client' | 'server' | 'both';
6
+ plugin: any;
7
+ }[];
8
+ };
9
+ export declare const defineConfig: (config?: Config) => import("vinxi").App;
10
+ export {};
11
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAWxC,KAAK,MAAM,GAAG;IACV,MAAM,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE;QACN,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;QACnC,MAAM,EAAE,GAAG,CAAC;KACf,EAAE,CAAC;CACP,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAQ,MAGpC,wBAoGA,CAAC"}
package/index.js ADDED
@@ -0,0 +1,97 @@
1
+ import { createApp } from 'vinxi';
2
+ import solid from 'vite-plugin-solid';
3
+ // @ts-expect-error
4
+ import { serverFunctions } from '@vinxi/server-functions/plugin';
5
+ import { ServerRouter, ClientRouter } from './utils/router.js';
6
+ import { join } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { cpSync, mkdirSync, existsSync } from 'node:fs';
9
+ import { normalize } from 'vinxi/lib/path';
10
+ export const defineConfig = (config = {
11
+ server: {},
12
+ plugins: [],
13
+ }) => {
14
+ let middlewarePath = join(process.cwd(), 'app', 'middleware.ts');
15
+ if (!existsSync(middlewarePath)) {
16
+ middlewarePath = join(process.cwd(), 'app', 'middleware.js');
17
+ }
18
+ const app = createApp({
19
+ server: {
20
+ ...config.server,
21
+ experimental: {
22
+ asyncContext: true,
23
+ },
24
+ },
25
+ routers: [
26
+ {
27
+ name: 'public',
28
+ type: 'static',
29
+ dir: './public',
30
+ base: '/',
31
+ },
32
+ {
33
+ name: 'client',
34
+ type: 'client',
35
+ target: 'browser',
36
+ handler: normalize(fileURLToPath(new URL('./client.js', import.meta.url))),
37
+ plugins: () => [
38
+ ...(config.plugins
39
+ ?.filter(p => p.type === 'client' || p.type === 'both')
40
+ .map(p => p.plugin) || []),
41
+ serverFunctions.client({
42
+ runtime: normalize(fileURLToPath(new URL('./utils/server-action.client.js', import.meta.url))),
43
+ }),
44
+ solid({ ssr: true }),
45
+ ],
46
+ base: '/_build',
47
+ routes: (router, app) => {
48
+ return new ClientRouter({
49
+ dir: join(process.cwd(), 'app'),
50
+ extensions: ['jsx', 'js', 'tsx', 'ts'],
51
+ }, router, app);
52
+ }
53
+ },
54
+ {
55
+ name: 'ssr',
56
+ type: 'http',
57
+ base: '/',
58
+ handler: normalize(fileURLToPath(new URL('./server.js', import.meta.url))),
59
+ target: 'server',
60
+ plugins: () => [
61
+ ...(config.plugins
62
+ ?.filter(p => p.type === 'server' || p.type === 'both')
63
+ .map(p => p.plugin) || []),
64
+ serverFunctions.server(),
65
+ solid({ ssr: true }),
66
+ ],
67
+ middleware: './app/middleware.ts',
68
+ routes: (router, app) => {
69
+ return new ServerRouter({
70
+ dir: join(process.cwd(), 'app'),
71
+ extensions: ['jsx', 'js', 'tsx', 'ts'],
72
+ }, router, app);
73
+ }
74
+ },
75
+ ],
76
+ });
77
+ app.hooks.afterEach(event => {
78
+ if (event.name === 'app:build:nitro:end') {
79
+ const [{ nitro }] = event.args;
80
+ const serverDir = nitro.options.output.serverDir;
81
+ const fromDir = join(process.cwd(), 'server-assets');
82
+ if (existsSync(fromDir)) {
83
+ const toDir = join(serverDir, 'server-assets');
84
+ mkdirSync(toDir, { recursive: true });
85
+ cpSync(fromDir, toDir, {
86
+ recursive: true,
87
+ force: true,
88
+ });
89
+ console.log(`✔ Copied server assets from ${fromDir} to ${toDir}`);
90
+ }
91
+ else {
92
+ console.log(`ℹ No server assets to copy from ${fromDir}`);
93
+ }
94
+ }
95
+ });
96
+ return app;
97
+ };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "solidstep",
3
+ "version": "0.1.0",
4
+ "description": "Next Step SolidJS Framework for building web applications.",
5
+ "type": "module",
6
+ "author": "HamzaKV <hamzakv333@gmail.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/HamzaKV/solidstep.git"
10
+ },
11
+ "license": "MIT",
12
+ "exports": {
13
+ ".": "./index.js",
14
+ "./utils/hooks/action-state": "./utils/hooks/action-state.js",
15
+ "./utils/cache": "./utils/cache.js",
16
+ "./utils/cookies": "./utils/cookies.js",
17
+ "./utils/cors": "./utils/cors.js",
18
+ "./utils/csp": "./utils/csp.js",
19
+ "./utils/csrf": "./utils/csrf.js",
20
+ "./utils/error-handler": "./utils/error-handler.js",
21
+ "./utils/fetch.client": "./utils/fetch.client.js",
22
+ "./utils/fetch.server": "./utils/fetch.server.js",
23
+ "./utils/loader": "./utils/loader.js",
24
+ "./utils/redirect": "./utils/redirect.js",
25
+ "./utils/server-only": "./utils/server-only.js",
26
+ "./utils/types": "./utils/types.js"
27
+ },
28
+ "scripts": {
29
+ "clean": "rimraf ./dist",
30
+ "copy-files:root": "copyfiles -u 0 README.md package.json generate/**/* LICENSE ./dist",
31
+ "build": "pnpm clean && tsc && pnpm copy-files:root",
32
+ "test:local": "pnpm build && cd ./dist && pnpm link --global",
33
+ "test:local:clean": "pnpm unlink && pnpm clean",
34
+ "roll": "pnpm build && cd dist && npm publish"
35
+ },
36
+ "keywords": [
37
+ "solidjs",
38
+ "web-development",
39
+ "typescript",
40
+ "npm",
41
+ "solidstep",
42
+ "framework"
43
+ ],
44
+ "dependencies": {
45
+ "@vinxi/server-functions": "0.5.1",
46
+ "seroval": "^1.3.2",
47
+ "seroval-plugins": "^1.3.2",
48
+ "solid-js": "^1.9.7",
49
+ "undici": "^7.15.0",
50
+ "vinxi": "^0.5.8"
51
+ },
52
+ "devDependencies": {
53
+ "copyfiles": "^2.4.1",
54
+ "rimraf": "^6.0.1",
55
+ "typescript": "^5.8.3",
56
+ "vite-plugin-solid": "^2.11.7"
57
+ }
58
+ }
package/server.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const handler: import("vinxi/http").EventHandler<import("vinxi/http").EventHandlerRequest, Promise<unknown>>;
2
+ export default handler;
3
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":"AAggBA,QAAA,MAAM,OAAO,+FA+TX,CAAC;AAEH,eAAe,OAAO,CAAC"}