create-buntui 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (46) hide show
  1. package/dist/main.js +4 -0
  2. package/package.json +8 -9
  3. package/templates/basic/package.json +3 -3
  4. package/templates/basic/src/apps/main/App.vue +29 -0
  5. package/templates/basic/src/apps/main/main.ts +12 -0
  6. package/templates/basic/src/shared/runApp.ts +14 -0
  7. package/templates/full/README.md +14 -12
  8. package/templates/full/package.json +3 -3
  9. package/templates/full/src/apps/main/components/BoxDemo.vue +80 -0
  10. package/templates/full/src/{components → apps/main/components}/ButtonDemo.vue +4 -4
  11. package/templates/full/src/apps/main/components/CheckboxDemo.vue +19 -0
  12. package/templates/full/src/{components → apps/main/components}/InputDemo.vue +6 -8
  13. package/templates/full/src/{components → apps/main/components}/ProgressDemo.vue +3 -3
  14. package/templates/full/src/{components → apps/main/components}/RadioDemo.vue +2 -2
  15. package/templates/full/src/{components → apps/main/components}/ScrollBoxDemo.vue +6 -11
  16. package/templates/full/src/{components → apps/main/components}/SelectDemo.vue +6 -8
  17. package/templates/full/src/apps/main/components/SwitchDemo.vue +19 -0
  18. package/templates/full/src/{components → apps/main/components}/TableDemo.vue +2 -4
  19. package/templates/full/src/apps/main/components/TextDemo.vue +66 -0
  20. package/templates/full/src/apps/main/components/TextareaDemo.vue +38 -0
  21. package/templates/full/src/apps/main/main.ts +12 -0
  22. package/templates/full/src/shared/runApp.ts +14 -0
  23. package/templates/sfc/README.md +5 -3
  24. package/templates/sfc/package.json +3 -3
  25. package/templates/sfc/src/apps/main/App.vue +42 -0
  26. package/templates/sfc/src/apps/main/main.ts +12 -0
  27. package/templates/sfc/src/shared/runApp.ts +14 -0
  28. package/dist/buntui.so +0 -0
  29. package/dist/index.js +0 -7
  30. package/templates/basic/scripts/build.ts +0 -65
  31. package/templates/basic/src/App.vue +0 -31
  32. package/templates/basic/src/dev.ts +0 -27
  33. package/templates/basic/src/main.ts +0 -15
  34. package/templates/full/scripts/build.ts +0 -66
  35. package/templates/full/src/components/BoxDemo.vue +0 -85
  36. package/templates/full/src/components/CheckboxDemo.vue +0 -19
  37. package/templates/full/src/components/SwitchDemo.vue +0 -19
  38. package/templates/full/src/components/TextDemo.vue +0 -72
  39. package/templates/full/src/components/TextareaDemo.vue +0 -37
  40. package/templates/full/src/dev.ts +0 -40
  41. package/templates/full/src/main.ts +0 -21
  42. package/templates/sfc/scripts/build.ts +0 -66
  43. package/templates/sfc/src/App.vue +0 -44
  44. package/templates/sfc/src/dev.ts +0 -40
  45. package/templates/sfc/src/main.ts +0 -21
  46. /package/templates/full/src/{App.vue → apps/main/App.vue} +0 -0
@@ -1,19 +0,0 @@
1
- <template>
2
- <Text :x="1" :y="3" :colorFg="'rgba(137,180,250,1)'" value="Switch widget — on/off toggle" />
3
-
4
- <Switch :x="1" :y="4" :label="'Dark mode'" @change="handleChange('Dark mode', $event)" />
5
- <Switch :x="1" :y="5" :label="'Notifications'" @change="handleChange('Notifications', $event)" />
6
- <Switch :x="1" :y="6" :label="'Disabled'" :disabled="true" />
7
-
8
- <Text :x="1" :y="8" :colorFg="'rgba(108,112,134,1)'" :value="log" />
9
- </template>
10
-
11
- <script setup lang="ts">
12
- import { ref } from '@vue/reactivity'
13
-
14
- const log = ref('Toggle a switch above')
15
-
16
- function handleChange(name: string, event: TuiSwitchChangeEvent) {
17
- log.value = `${name}: ${event.checked ? 'on' : 'off'}`
18
- }
19
- </script>
@@ -1,72 +0,0 @@
1
- <template>
2
- <Text :x="1" :y="3" :colorFg="'rgba(137,180,250,1)'" value="Text widget — display styled text" />
3
-
4
- <Box
5
- :x="1"
6
- :y="4"
7
- :width="45%"
8
- :height="5"
9
- :colorBg="'rgba(30,30,46,1)'"
10
- :borderColor="'rgba(137,180,250,0.5)'"
11
- borderStyle="rounded"
12
- :direction="'vertical'"
13
- :gap="1"
14
- :paddingTop="1"
15
- :paddingLeft="1"
16
- >
17
- <Text :colorFg="'rgba(137,180,250,1)'" value="Font styles" />
18
- <Text styleModifier="bold" :colorFg="'rgba(205,214,244,1)'" value="Bold text" />
19
- <Text styleModifier="italic" :colorFg="'rgba(205,214,244,1)'" value="Italic text" />
20
- </Box>
21
-
22
- <Box
23
- x="50%"
24
- :y="4"
25
- width="45%"
26
- :height="5"
27
- :colorBg="'rgba(30,30,46,1)'"
28
- :borderColor="'rgba(166,227,161,0.5)'"
29
- borderStyle="rounded"
30
- :direction="'vertical'"
31
- :gap="1"
32
- :paddingTop="1"
33
- :paddingLeft="1"
34
- >
35
- <Text :colorFg="'rgba(166,227,161,1)'" value="Colors" />
36
- <Text :colorFg="'rgba(243,139,168,1)'" value="Red " />
37
- <Text :colorFg="'rgba(137,180,250,1)'" value="Blue " />
38
- <Text :colorFg="'rgba(166,227,161,1)'" value="Green" />
39
- </Box>
40
-
41
- <Box
42
- :x="1"
43
- :y="10"
44
- width="95%"
45
- :height="3"
46
- :colorBg="'rgba(30,30,46,1)'"
47
- :borderColor="'rgba(250,179,135,0.5)'"
48
- borderStyle="rounded"
49
- :direction="'vertical'"
50
- :gap="1"
51
- :paddingTop="1"
52
- :paddingLeft="1"
53
- >
54
- <Text :colorFg="'rgba(250,179,135,1)'" value="Dynamic clock:" />
55
- <Text :colorFg="'rgba(205,214,244,1)'" :value="clock" />
56
- </Box>
57
- </template>
58
-
59
- <script setup lang="ts">
60
- import { ref, computed } from '@vue/reactivity'
61
-
62
- const elapsed = ref(0)
63
- setInterval(() => {
64
- elapsed.value += 1
65
- }, 1000)
66
-
67
- const clock = computed(() => {
68
- elapsed.value
69
- const now = new Date()
70
- return now.toLocaleTimeString()
71
- })
72
- </script>
@@ -1,37 +0,0 @@
1
- <template>
2
- <Text :x="1" :y="3" :colorFg="'rgba(137,180,250,1)'" value="Textarea widget — multi-line text editor" />
3
-
4
- <Box
5
- :x="1"
6
- :y="4"
7
- :width="50"
8
- :height="6"
9
- :colorBg="'rgba(30,30,46,1)'"
10
- :borderColor="'rgba(137,180,250,0.5)'"
11
- borderStyle="rounded"
12
- :direction="'vertical'"
13
- :gap="1"
14
- :paddingTop="1"
15
- :paddingLeft="1"
16
- >
17
- <Text :colorFg="'rgba(108,112,134,1)'" value="Type and press Ctrl+Enter to submit:" />
18
- <Textarea
19
- :width="46"
20
- :height="3"
21
- :placeholder="'Enter multi-line text...'"
22
- @submit="handleSubmit"
23
- />
24
- </Box>
25
-
26
- <Text :x="1" :y="11" :colorFg="'rgba(166,227,161,1)'" :value="submittedValue" />
27
- </template>
28
-
29
- <script setup lang="ts">
30
- import { ref } from '@vue/reactivity'
31
-
32
- const submittedValue = ref('Submit result appears here')
33
-
34
- function handleSubmit(event: TuiSubmitEvent) {
35
- submittedValue.value = `Submitted: "${event.value}"`
36
- }
37
- </script>
@@ -1,40 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs';
3
- import {createDevServer, CORE_REGISTRY, type DevServerOptions} from '@buntui/compiler';
4
- import {mountHmrErrorOverlay, type HmrErrorOverlayHandle} from '@buntui/extensions/hmr-error-overlay';
5
- import {ENTRY, run} from './main';
6
-
7
- const DEV_DIR = path.join(import.meta.dir, '.dev');
8
- fs.mkdirSync(DEV_DIR, {recursive: true});
9
-
10
- const {scene} = run({logFilePath: DEV_DIR});
11
-
12
- const VUE_FILE = path.join(import.meta.dir, ENTRY);
13
-
14
- let errorOverlay: HmrErrorOverlayHandle | undefined;
15
-
16
- createDevServer({
17
- file: VUE_FILE,
18
- tempDir: DEV_DIR,
19
- compileOptions: {
20
- registry: CORE_REGISTRY,
21
- codegen: {
22
- coreModuleId: '@buntui/core',
23
- reactivityModuleId: '@vue/reactivity',
24
- },
25
- },
26
- onClear() {
27
- errorOverlay?.dismiss();
28
- errorOverlay = undefined;
29
- scene.clearWidgets();
30
- },
31
- onReload(setupFn: (scene: unknown) => void) {
32
- errorOverlay?.dismiss();
33
- errorOverlay = undefined;
34
- setupFn(scene);
35
- },
36
- onError(error: Error) {
37
- errorOverlay?.dismiss();
38
- errorOverlay = mountHmrErrorOverlay(scene, error);
39
- },
40
- } satisfies DevServerOptions);
@@ -1,21 +0,0 @@
1
- import {createApp} from '@buntui/core';
2
- import App from './App.vue';
3
-
4
- export const ENTRY = 'App.vue';
5
-
6
- export function run(devOptions: {logFilePath?: string} = {}) {
7
- const app = createApp({
8
- logLevel: 'debug',
9
- clearLog: true,
10
- tickRate: 60,
11
- renderRate: 24,
12
- ...devOptions,
13
- });
14
- const scene = app.createScene(App, {bgHexRgb: 0x1A_1B_26, visible: true});
15
- app.start();
16
- return {app, scene};
17
- }
18
-
19
- if (import.meta.main) {
20
- run();
21
- }
@@ -1,66 +0,0 @@
1
- import process from 'node:process';
2
- import path from 'node:path';
3
- import fs from 'node:fs';
4
- import {compile, CORE_REGISTRY} from '@buntui/compiler';
5
- import {getBinaryPath} from '@buntui/native';
6
-
7
- const result = await Bun.build({
8
- entrypoints: ['src/main.ts'],
9
- outdir: 'dist',
10
- target: 'bun',
11
- minify: true,
12
- plugins: [
13
- {
14
- name: 'buntui-vue',
15
- setup(build) {
16
- build.onLoad({filter: /\.vue$/v}, async args => {
17
- const source = await Bun.file(args.path).text();
18
- const compiled = compile(source, {
19
- filename: args.path,
20
- registry: CORE_REGISTRY,
21
- codegen: {
22
- coreModuleId: '@buntui/core',
23
- reactivityModuleId: '@vue/reactivity',
24
- },
25
- });
26
- return {contents: compiled.code, loader: 'ts'};
27
- });
28
- },
29
- },
30
- ],
31
- });
32
-
33
- if (!result.success) {
34
- for (const error of result.logs) {
35
- console.error(error);
36
- }
37
-
38
- process.exit(1);
39
- }
40
-
41
- for (const output of result.outputs) {
42
- console.log(`Built: ${output.path} (${(output.size / 1024).toFixed(1)} KB)`);
43
- }
44
-
45
- function getBinaryExt(): string {
46
- if (process.platform === 'win32') return 'dll';
47
- if (process.platform === 'darwin') return 'dylib';
48
- return 'so';
49
- }
50
-
51
- const binaryName = `buntui.${getBinaryExt()}`;
52
- const nativePath = getBinaryPath();
53
- const dllSearchPaths = [
54
- ...(nativePath ? [nativePath] : []),
55
- path.resolve(import.meta.dir, '..', 'node_modules', '@buntui', 'core', binaryName),
56
- path.resolve(import.meta.dir, '..', binaryName),
57
- ];
58
-
59
- for (const candidate of dllSearchPaths) {
60
- if (fs.existsSync(candidate)) {
61
- const dest = path.resolve(import.meta.dir, '..', 'dist', binaryName);
62
- fs.copyFileSync(candidate, dest);
63
- console.log(`Copied: ${binaryName} -> dist/`);
64
- break;
65
- }
66
- }
@@ -1,44 +0,0 @@
1
- <template>
2
- <Box
3
- :x="'20%'"
4
- :y="'25%'"
5
- :width="'60%'"
6
- :height="12"
7
- :colorBg="'rgba(30,30,46,1)'"
8
- :borderColor="'rgba(137,180,250,1)'"
9
- borderStyle="rounded"
10
- :direction="'vertical'"
11
- :gap="1"
12
- :align="'center'"
13
- :paddingTop="1"
14
- :paddingBottom="1"
15
- :paddingLeft="2"
16
- :paddingRight="2"
17
- >
18
- <Text :colorFg="'rgba(137,180,250,1)'" :value="title" styleModifier="bold" />
19
- <Text :colorFg="'rgba(166,227,161,1)'" value="SFC template with hot reload" />
20
- <Text :colorFg="'rgba(205,214,244,1)'" value="Edit src/App.vue to get started" />
21
- <Text :colorFg="'rgba(108,112,134,1)'" :value="clock" />
22
- <Box :direction="'horizontal'" :gap="2" :align="'center'">
23
- <Button :value="'Count: ' + count" @click="increment" />
24
- </Box>
25
- </Box>
26
- </template>
27
-
28
- <script setup lang="ts">
29
- import { onTick } from '@buntui/core'
30
- import { ref } from '@vue/reactivity'
31
-
32
- const title = '{{name}}'
33
- const clock = ref('')
34
- const count = ref(0)
35
-
36
- onTick(() => {
37
- const now = new Date()
38
- clock.value = now.toLocaleTimeString()
39
- })
40
-
41
- function increment() {
42
- count.value++
43
- }
44
- </script>
@@ -1,40 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs';
3
- import {createDevServer, CORE_REGISTRY, type DevServerOptions} from '@buntui/compiler';
4
- import {mountHmrErrorOverlay, type HmrErrorOverlayHandle} from '@buntui/extensions/hmr-error-overlay';
5
- import {ENTRY, run} from './main';
6
-
7
- const DEV_DIR = path.join(import.meta.dir, '.dev');
8
- fs.mkdirSync(DEV_DIR, {recursive: true});
9
-
10
- const {scene} = run({logFilePath: DEV_DIR});
11
-
12
- const VUE_FILE = path.join(import.meta.dir, ENTRY);
13
-
14
- let errorOverlay: HmrErrorOverlayHandle | undefined;
15
-
16
- createDevServer({
17
- file: VUE_FILE,
18
- tempDir: DEV_DIR,
19
- compileOptions: {
20
- registry: CORE_REGISTRY,
21
- codegen: {
22
- coreModuleId: '@buntui/core',
23
- reactivityModuleId: '@vue/reactivity',
24
- },
25
- },
26
- onClear() {
27
- errorOverlay?.dismiss();
28
- errorOverlay = undefined;
29
- scene.clearWidgets();
30
- },
31
- onReload(setupFn: (scene: unknown) => void) {
32
- errorOverlay?.dismiss();
33
- errorOverlay = undefined;
34
- setupFn(scene);
35
- },
36
- onError(error: Error) {
37
- errorOverlay?.dismiss();
38
- errorOverlay = mountHmrErrorOverlay(scene, error);
39
- },
40
- } satisfies DevServerOptions);
@@ -1,21 +0,0 @@
1
- import {createApp} from '@buntui/core';
2
- import App from './App.vue';
3
-
4
- export const ENTRY = 'App.vue';
5
-
6
- export function run(devOptions: {logFilePath?: string} = {}) {
7
- const app = createApp({
8
- logLevel: 'debug',
9
- clearLog: true,
10
- tickRate: 60,
11
- renderRate: 24,
12
- ...devOptions,
13
- });
14
- const scene = app.createScene(App, {bgHexRgb: 0x1A_1B_26, visible: true});
15
- app.start();
16
- return {app, scene};
17
- }
18
-
19
- if (import.meta.main) {
20
- run();
21
- }