@mndw/cli 0.0.0-stage → 0.1.2
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/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/meta.json +1821 -0
- package/dist/mndw.js +4011 -0
- package/host-dev/assets/_virtual_sandbox-manifest-DbTeSIus.js +1 -0
- package/host-dev/assets/_virtual_sandbox-plugin-Cg-1CvkF.js +1 -0
- package/host-dev/assets/index-Bks-EVsE.js +94 -0
- package/host-dev/assets/index-TmL5gfki.css +1 -0
- package/host-dev/assets/sandbox-url-0nkeUf58.js +1 -0
- package/host-dev/assets/sprite-DIkKar2y.svg +189 -0
- package/host-dev/assets/ticker-pool.worker-DJA1ERT2.js +1 -0
- package/host-dev/index.html +33 -0
- package/host-dev/shared/angular-common@21.2.18.js +30 -0
- package/host-dev/shared/angular-compiler@21.2.18.js +84 -0
- package/host-dev/shared/angular-core@21.2.18.js +122 -0
- package/host-dev/shared/angular-platform-browser@21.2.18.js +34 -0
- package/host-dev/shared/d3@7.9.0.js +5 -0
- package/host-dev/shared/hash-wasm@4.12.0.js +10 -0
- package/host-dev/shared/mndw-ui@0.1.2.js +1656 -0
- package/host-dev/shared/rci-tools-core@0.6.0.js +15 -0
- package/host-dev/shared/rxjs-operators@7.8.2.js +3 -0
- package/host-dev/shared/rxjs@7.8.2.js +3 -0
- package/host-dev/shared/vue@3.5.39.js +56 -0
- package/host-dev/shared/zone@0.15.1.js +11 -0
- package/package.json +77 -3
- package/templates/angular/i18n/en.json +13 -0
- package/templates/angular/i18n/ru.json +13 -0
- package/templates/angular/src/app.component.ts +57 -0
- package/templates/angular/src/index.ts +21 -0
- package/templates/angular/src/l10n.test.ts +50 -0
- package/templates/angular/src/table.test.ts +59 -0
- package/templates/angular/tsconfig.json +18 -0
- package/templates/backend/main.sh +7 -0
- package/templates/go/backend/cmd/__MNDW_NAME__d/main.go +20 -0
- package/templates/go/backend/go.mod +6 -0
- package/templates/go/backend/integration_test.go +174 -0
- package/templates/go/backend/internal/httpapi/server.go +87 -0
- package/templates/go/backend/internal/httpapi/server_test.go +63 -0
- package/templates/go/gitignore +6 -0
- package/templates/go/i18n/en.json +8 -0
- package/templates/go/i18n/ru.json +8 -0
- package/templates/go/manifest.json +25 -0
- package/templates/go/package.json +20 -0
- package/templates/go/src/index.css +31 -0
- package/templates/go/src/index.test.ts +59 -0
- package/templates/go/src/index.ts +92 -0
- package/templates/go/src/l10n.test.ts +66 -0
- package/templates/go/src/test-helpers.ts +6 -0
- package/templates/svelte/i18n/en.json +13 -0
- package/templates/svelte/i18n/ru.json +13 -0
- package/templates/svelte/src/App.svelte +102 -0
- package/templates/svelte/src/TableNameCell.svelte +10 -0
- package/templates/svelte/src/index.ts +14 -0
- package/templates/svelte/src/l10n.test.ts +45 -0
- package/templates/svelte/src/table.test.ts +53 -0
- package/templates/svelte/vitest.config.ts +9 -0
- package/templates/vanilla/i18n/en.json +7 -0
- package/templates/vanilla/i18n/ru.json +7 -0
- package/templates/vanilla/src/index.css +31 -0
- package/templates/vanilla/src/index.ts +65 -0
- package/templates/vanilla/src/l10n.test.ts +44 -0
- package/templates/vue/i18n/en.json +13 -0
- package/templates/vue/i18n/ru.json +13 -0
- package/templates/vue/src/App.vue +80 -0
- package/templates/vue/src/TableNameCell.vue +12 -0
- package/templates/vue/src/env.d.ts +6 -0
- package/templates/vue/src/index.ts +16 -0
- package/templates/vue/src/l10n.test.ts +45 -0
- package/templates/vue/src/table.test.ts +53 -0
- package/templates/vue/vitest.config.ts +6 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {computed, ref, watchEffect} from 'vue';
|
|
3
|
+
import type {PluginContext} from '@mndw/sdk';
|
|
4
|
+
import {column, type MndwTableProps} from '@mndw/ui';
|
|
5
|
+
import {useTheme, useTranslator} from '@mndw/sdk/vue';
|
|
6
|
+
import {vueCell} from '@mndw/ui-vue';
|
|
7
|
+
import TableNameCell from './TableNameCell.vue';
|
|
8
|
+
|
|
9
|
+
interface TableRow {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const {ctx} = defineProps<{ctx: PluginContext}>();
|
|
15
|
+
const translator = useTranslator(ctx.i18n);
|
|
16
|
+
const theme = useTheme(ctx);
|
|
17
|
+
const rows = computed<TableRow[]>(() => [
|
|
18
|
+
{id: 'first', name: translator.t('table.first')},
|
|
19
|
+
{id: 'second', name: translator.t('table.second')},
|
|
20
|
+
]);
|
|
21
|
+
const columns = computed(() => [
|
|
22
|
+
column<TableRow>()({
|
|
23
|
+
id: 'name',
|
|
24
|
+
label: translator.t('table.column'),
|
|
25
|
+
accessor: (row) => row.name,
|
|
26
|
+
renderer: vueCell<TableRow, string>()(TableNameCell),
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
29
|
+
const table = ref<(HTMLElement & MndwTableProps<TableRow>) | null>(null);
|
|
30
|
+
|
|
31
|
+
watchEffect(() => {
|
|
32
|
+
if (table.value === null) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Object.assign(table.value, {
|
|
37
|
+
columns: columns.value,
|
|
38
|
+
rows: rows.value,
|
|
39
|
+
rowKey: 'id',
|
|
40
|
+
caption: translator.t('table.caption'),
|
|
41
|
+
columnMenu: false,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<div class="wrap" :data-theme="theme">
|
|
48
|
+
<h3 class="title" data-testid="l10n-probe" data-plugin-label="__MNDW_LABEL__">{{ translator.t('l10n.probe') }}</h3>
|
|
49
|
+
<p class="device">Device: {{ ctx.deviceInfo.deviceName }}</p>
|
|
50
|
+
<p class="result">{{ translator.t('l10n.result') }}</p>
|
|
51
|
+
<mndw-table
|
|
52
|
+
ref="table"
|
|
53
|
+
:columns.prop="columns"
|
|
54
|
+
:rows.prop="rows"
|
|
55
|
+
:rowKey.prop="'id'"
|
|
56
|
+
:caption.prop="translator.t('table.caption')"
|
|
57
|
+
:columnMenu.prop="false"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<style scoped>
|
|
63
|
+
.wrap {
|
|
64
|
+
padding: var(--mndw-space-4);
|
|
65
|
+
font-family: var(--mndw-font-sans);
|
|
66
|
+
color: var(--mndw-text);
|
|
67
|
+
background: var(--mndw-surface);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.title {
|
|
71
|
+
margin: 0 0 var(--mndw-space-2);
|
|
72
|
+
font-size: var(--mndw-text-lg);
|
|
73
|
+
font-weight: var(--mndw-weight-semibold);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.device {
|
|
77
|
+
margin: 0;
|
|
78
|
+
color: var(--mndw-text-muted);
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type {PluginContext, PluginInstance} from '@mndw/sdk';
|
|
2
|
+
import {createApp} from 'vue';
|
|
3
|
+
|
|
4
|
+
import App from './App.vue';
|
|
5
|
+
|
|
6
|
+
export function createInstance(container: HTMLElement, ctx: PluginContext): PluginInstance {
|
|
7
|
+
const app = createApp(App, {ctx});
|
|
8
|
+
|
|
9
|
+
app.mount(container);
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
unmount() {
|
|
13
|
+
app.unmount();
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import {createApp, nextTick} from 'vue';
|
|
4
|
+
import type {PluginContext} from '@mndw/sdk';
|
|
5
|
+
import {createTestI18n, createTestPluginContext} from '@mndw/sdk/testing';
|
|
6
|
+
import {describe, expect, it} from 'vitest';
|
|
7
|
+
import App from './App.vue';
|
|
8
|
+
|
|
9
|
+
const contextFor = (i18n: ReturnType<typeof createTestI18n>): PluginContext => createTestPluginContext({i18n}).context;
|
|
10
|
+
|
|
11
|
+
describe('generated Vue locale reactivity', () => {
|
|
12
|
+
it('updates the same probe node without remounting', async () => {
|
|
13
|
+
const en = {l10n: {probe: 'English probe', result: 'English result'}};
|
|
14
|
+
const ru = {l10n: {probe: 'Русский probe', result: 'Русский результат'}};
|
|
15
|
+
const i18n = createTestI18n(en, 'en');
|
|
16
|
+
const root = document.createElement('div');
|
|
17
|
+
const app = createApp(App, {ctx: contextFor(i18n)});
|
|
18
|
+
app.mount(root);
|
|
19
|
+
const probe = root.querySelector('[data-testid="l10n-probe"]');
|
|
20
|
+
|
|
21
|
+
expect(en.l10n.probe).not.toBe(ru.l10n.probe);
|
|
22
|
+
expect(probe?.textContent).toBe(en.l10n.probe);
|
|
23
|
+
i18n.setLocale('ru', ru);
|
|
24
|
+
await nextTick();
|
|
25
|
+
|
|
26
|
+
expect(root.querySelector('[data-testid="l10n-probe"]')).toBe(probe);
|
|
27
|
+
expect(probe?.textContent).toBe(ru.l10n.probe);
|
|
28
|
+
app.unmount();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('updates data-theme when the host theme changes', async () => {
|
|
32
|
+
const fixture = createTestPluginContext();
|
|
33
|
+
const root = document.createElement('div');
|
|
34
|
+
const app = createApp(App, {ctx: fixture.context});
|
|
35
|
+
app.mount(root);
|
|
36
|
+
|
|
37
|
+
expect(root.querySelector('.wrap')?.getAttribute('data-theme')).toBe('light');
|
|
38
|
+
fixture.setTheme('dark');
|
|
39
|
+
await nextTick();
|
|
40
|
+
expect(root.querySelector('.wrap')?.getAttribute('data-theme')).toBe('dark');
|
|
41
|
+
|
|
42
|
+
app.unmount();
|
|
43
|
+
fixture.unmount();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import {createTestI18n, createTestPluginContext} from '@mndw/sdk/testing';
|
|
4
|
+
import {defineMndwUi} from '@mndw/ui';
|
|
5
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
6
|
+
import {nextTick} from 'vue';
|
|
7
|
+
import {createInstance} from './index.js';
|
|
8
|
+
|
|
9
|
+
type TableElement = HTMLElement & {updateComplete: Promise<unknown>};
|
|
10
|
+
|
|
11
|
+
const catalog = {
|
|
12
|
+
table: {
|
|
13
|
+
caption: 'Example records',
|
|
14
|
+
column: 'Name',
|
|
15
|
+
first: 'Alpha',
|
|
16
|
+
second: 'Beta',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
defineMndwUi();
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
document.body.innerHTML = '';
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('generated Vue table', () => {
|
|
27
|
+
it('renders localized rows through vueCell', async () => {
|
|
28
|
+
const fixture = createTestPluginContext({i18n: createTestI18n(catalog)});
|
|
29
|
+
const container = document.createElement('div');
|
|
30
|
+
document.body.append(container);
|
|
31
|
+
const instance = createInstance(container, fixture.context);
|
|
32
|
+
await nextTick();
|
|
33
|
+
|
|
34
|
+
const table = container.querySelector('mndw-table') as TableElement | null;
|
|
35
|
+
|
|
36
|
+
if (table === null) {
|
|
37
|
+
throw new Error('expected generated mndw-table');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
await table.updateComplete;
|
|
41
|
+
expect(table.shadowRoot?.querySelectorAll('[part="row"]')).toHaveLength(2);
|
|
42
|
+
expect(table.shadowRoot?.querySelector('[part="caption"]')?.textContent).toBe(catalog.table.caption);
|
|
43
|
+
expect(table.shadowRoot?.querySelector('[part="header-cell"]')?.textContent).toContain(catalog.table.column);
|
|
44
|
+
expect(Array.from(table.querySelectorAll('[data-testid="table-name-cell"]')).map((cell) => cell.textContent))
|
|
45
|
+
.toEqual([
|
|
46
|
+
catalog.table.first,
|
|
47
|
+
catalog.table.second,
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
instance.unmount();
|
|
51
|
+
fixture.unmount();
|
|
52
|
+
});
|
|
53
|
+
});
|