@cslug/vue 0.11.1 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cslug/vue",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "Vue views rendered on the server, components hydrated as islands, composables and asset build.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,9 +33,9 @@
33
33
  "bun": ">=1.3.14"
34
34
  },
35
35
  "peerDependencies": {
36
- "@cslug/core": "0.11.1",
37
- "@cslug/http": "0.11.1",
38
- "@cslug/validation": "0.11.1",
36
+ "@cslug/core": "0.12.0",
37
+ "@cslug/http": "0.12.0",
38
+ "@cslug/validation": "0.12.0",
39
39
  "vue": "^3.5.0",
40
40
  "sass": "^1.80.0",
41
41
  "tailwindcss": "^4.0.0",
@@ -0,0 +1,22 @@
1
+ import { join } from 'node:path'
2
+ import { defineGenerator } from '@cslug/core'
3
+
4
+ const STUBS = join(import.meta.dir, '../stubs')
5
+
6
+ /** `cslug make:view bookings/show` → `resources/views/bookings/show.vue` (a page, with typed props). */
7
+ export const MakeViewCommand = defineGenerator({
8
+ kind: 'view',
9
+ description: 'Create a page view (resources/views/…)',
10
+ stubs: STUBS,
11
+ suffix: '',
12
+ files: (n) => [{ stub: 'view.stub', target: `resources/views/${n.file}.vue` }],
13
+ })
14
+
15
+ /** `cslug make:component day-map` → `resources/components/day-map.vue` (an island where used with `hydrate`). */
16
+ export const MakeComponentCommand = defineGenerator({
17
+ kind: 'component',
18
+ description: 'Create a component (resources/components/…)',
19
+ stubs: STUBS,
20
+ suffix: '',
21
+ files: (n) => [{ stub: 'component.stub', target: `resources/components/${n.file}.vue` }],
22
+ })
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export { buildAssets } from './build'
9
9
  export { BuildCommand, TypecheckCommand } from './commands'
10
10
  export { type CompiledSfc, type CompileOptions, compileSfc, componentId, rewriteIslands } from './compiler'
11
11
  export { formatDate, formatDuration, formatMoney, type RequestInfo, route, useRequest, useT } from './composables'
12
+ export { MakeComponentCommand, MakeViewCommand } from './generators'
12
13
  export { registerVueLoader } from './loader'
13
14
  export { mountIslands } from './mount-stub'
14
15
  export { VueProvider } from './provider'
package/src/provider.ts CHANGED
@@ -2,6 +2,7 @@ import { ServiceProvider } from '@cslug/core'
2
2
  import { Router } from '@cslug/http'
3
3
  import { assetConfig, BuildCommand, TypecheckCommand } from './commands'
4
4
  import { liveRoute, startDev } from './dev'
5
+ import { MakeComponentCommand, MakeViewCommand } from './generators'
5
6
  import { registerVueLoader } from './loader'
6
7
 
7
8
  /**
@@ -13,7 +14,7 @@ export class VueProvider extends ServiceProvider {
13
14
  private stopDev?: () => void
14
15
 
15
16
  register() {
16
- this.commands([BuildCommand, TypecheckCommand])
17
+ this.commands([BuildCommand, TypecheckCommand, MakeViewCommand, MakeComponentCommand])
17
18
  registerVueLoader(this.app.rootDir, { production: this.app.config('app.env') === 'production' })
18
19
  }
19
20
 
@@ -0,0 +1,14 @@
1
+ <script setup lang="ts">
2
+ // an island where you use it with hydrate="visible" (or load, idle, media:…); static HTML without it
3
+ const props = defineProps<{ label: string }>()
4
+ </script>
5
+
6
+ <template>
7
+ <div class="{{ kebab }}">{{ props.label }}</div>
8
+ </template>
9
+
10
+ <style scoped lang="scss">
11
+ .{{ kebab }} {
12
+ display: block;
13
+ }
14
+ </style>
@@ -0,0 +1,12 @@
1
+ <script setup lang="ts">
2
+ import Layout from '#views/layouts/default.vue'
3
+
4
+ // typed props: view({{ base }}Page, { title }) is checked against them by `cslug typecheck`
5
+ const props = defineProps<{ title: string }>()
6
+ </script>
7
+
8
+ <template>
9
+ <Layout :title="props.title">
10
+ <h1>{{ props.title }}</h1>
11
+ </Layout>
12
+ </template>