@antelopejs/dms 0.20.3 → 0.20.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.
- package/CHANGELOG.md +21 -0
- package/dist/implementations/dms-builder/engine/compose-page.js +3 -2
- package/dist/implementations/dms-builder/engine/compose-page.js.map +1 -1
- package/dist/mcp/page-verify/index.d.ts +1 -0
- package/dist/mcp/page-verify/index.js +1 -0
- package/dist/mcp/page-verify/index.js.map +1 -1
- package/dist/mcp/page-verify/redact-report.d.ts +2 -0
- package/dist/mcp/page-verify/redact-report.js +120 -0
- package/dist/mcp/page-verify/redact-report.js.map +1 -0
- package/dist/mcp/page-verify/render.js +4 -1
- package/dist/mcp/page-verify/render.js.map +1 -1
- package/dist/mcp/redact.d.ts +87 -0
- package/dist/mcp/redact.js +139 -0
- package/dist/mcp/redact.js.map +1 -0
- package/dist/mcp/tools/builder-compose.js +11 -2
- package/dist/mcp/tools/builder-compose.js.map +1 -1
- package/dist/mcp/tools/builder-project.js +56 -23
- package/dist/mcp/tools/builder-project.js.map +1 -1
- package/dist/mcp/tools/builder-queries.js +41 -4
- package/dist/mcp/tools/builder-queries.js.map +1 -1
- package/dist/mcp/tools/builder-shared.d.ts +3 -1
- package/dist/mcp/tools/builder-shared.js +5 -0
- package/dist/mcp/tools/builder-shared.js.map +1 -1
- package/dist/mcp/tools/database.js +3 -2
- package/dist/mcp/tools/database.js.map +1 -1
- package/dist/mcp/tools/page-verify.js +3 -2
- package/dist/mcp/tools/page-verify.js.map +1 -1
- package/frontend-vue/eslint-globals.generated.mjs +259 -942
- package/frontend-vue/layers/dms-core/app/build/composables/api-error.ts +46 -23
- package/frontend-vue/layers/dms-core/app/build/composables/auth/usePermissionPreview.ts +34 -23
- package/frontend-vue/layers/dms-core/app/build/composables/user/preferencesCookie.ts +8 -2
- package/frontend-vue/layers/dms-core/app/build/composables/user/tablePreferences.ts +11 -5
- package/frontend-vue/layers/dms-core/app/build/utils/crossTab.ts +4 -2
- package/frontend-vue/layers/dms-core/app/build/utils/json.ts +31 -0
- package/frontend-vue/layers/dms-core/app/build/utils/permission-preview.ts +6 -11
- package/frontend-vue/layers/dms-core/app/build/utils/record.ts +4 -0
- package/frontend-vue/layers/dms-core/app/build/utils/sharedRealtimeConnection.ts +56 -36
- package/frontend-vue/layers/dms-core/app/composables/auth/useApiData.ts +2 -2
- package/frontend-vue/layers/dms-core/app/composables/auth/useAuthFetch.ts +6 -1
- package/frontend-vue/layers/dms-core/app/composables/auth/useCurrentUser.ts +3 -2
- package/frontend-vue/layers/dms-core/app/composables/auth/useLogout.ts +3 -2
- package/frontend-vue/layers/dms-core/app/composables/auth/useMultiAccount.ts +15 -14
- package/frontend-vue/layers/dms-core/app/composables/auth/useSessionRecovery.ts +21 -8
- package/frontend-vue/layers/dms-core/app/composables/data-types/useDataType.ts +3 -3
- package/frontend-vue/layers/dms-core/app/composables/page/useSiteLayout.ts +11 -9
- package/frontend-vue/layers/dms-core/app/composables/period/periodLink.ts +3 -2
- package/frontend-vue/layers/dms-core/app/composables/period/usePeriod.ts +2 -2
- package/frontend-vue/layers/dms-core/app/composables/realtime/usePageRealtime.ts +10 -3
- package/frontend-vue/layers/dms-core/app/composables/realtime/useSseStream.ts +22 -16
- package/frontend-vue/layers/dms-core/app/composables/realtime/useUserRealtime.ts +68 -46
- package/frontend-vue/layers/dms-core/app/composables/useApiErrorPresenter.ts +22 -11
- package/frontend-vue/layers/dms-core/app/composables/useEventedAction.ts +4 -1
- package/frontend-vue/layers/dms-core/app/composables/useFieldErrors.ts +14 -6
- package/frontend-vue/layers/dms-core/app/composables/user/usePreferences.ts +8 -3
- package/frontend-vue/layers/dms-core/app/composables/watch/useWatch.ts +17 -8
- package/frontend-vue/layers/dms-core/app/types/module-store.ts +3 -1
- package/frontend-vue/layers/dms-core/app/types/page.ts +3 -1
- package/frontend-vue/layers/dms-core/app/utils/dedupedRefresh.ts +2 -2
- package/frontend-vue/layers/dms-core/app/utils/formatter.ts +5 -5
- package/frontend-vue/layers/dms-core/app/utils/menu.ts +12 -4
- package/frontend-vue/layers/dms-core/app/utils/pageQuery.ts +7 -4
- package/frontend-vue/layers/dms-core/app/utils/row-action-rule-evaluator.ts +7 -3
- package/frontend-vue/layers/dms-core/app/utils/stringTypeParser.ts +8 -10
- package/frontend-vue/layers/dms-core/app/utils/type-check.ts +25 -12
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupEditOverlay.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupIndex.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspector.vue +3 -2
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspectorField.vue +5 -2
- package/frontend-vue/layers/dms-ui/app/build/components/containers/drawer/DynamicDrawer.vue +4 -3
- package/frontend-vue/layers/dms-ui/app/build/components/containers/modal/DynamicModal.vue +3 -2
- package/frontend-vue/layers/dms-ui/app/build/components/containers/row/RowHeader.vue +2 -1
- package/frontend-vue/layers/dms-ui/app/build/components/period/PeriodRangeCalendar.vue +10 -7
- package/frontend-vue/layers/dms-ui/app/build/components/sortable/SortableList.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/build/components/table/FiltersRow.vue +20 -18
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuColumns.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuDensity.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuFilter.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuImport.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuPage.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuRoot.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuSort.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuViewMode.vue +21 -19
- package/frontend-vue/layers/dms-ui/app/build/components/table/RowSelection.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/Table.types.ts +4 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableActions.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableMenu.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TablePagination.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableRoot.vue +3 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableTabs.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableViews.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentFilters.ts +4 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentPreferences.ts +4 -3
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentRows.ts +4 -3
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentTheme.ts +11 -0
- package/frontend-vue/layers/dms-ui/app/build/components/table-view/CardsDisplay.vue +35 -9
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/mockups/resync.ts +9 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +34 -25
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +52 -26
- package/frontend-vue/layers/dms-ui/app/build/utils/calendarDay.ts +4 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/characterCount.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/dispatchQuickActionTarget.ts +16 -11
- package/frontend-vue/layers/dms-ui/app/build/utils/fieldOptionsI18n.ts +23 -21
- package/frontend-vue/layers/dms-ui/app/build/utils/json.ts +74 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/link.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +4 -4
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupCatalog.ts +59 -50
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupDrop.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupEdit.ts +8 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +34 -28
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStamp.ts +11 -3
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStream.ts +5 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/streamHighlight.ts +8 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/urlVariables.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/components/RecursiveComponent.vue +3 -6
- package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +5 -4
- package/frontend-vue/layers/dms-ui/app/components/blocks/BannerBlock.vue +1 -2
- package/frontend-vue/layers/dms-ui/app/components/card/NavCard.vue +4 -1
- package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +62 -13
- package/frontend-vue/layers/dms-ui/app/components/chart/ChartBlock.vue +18 -6
- package/frontend-vue/layers/dms-ui/app/components/code-snippet/CodeSnippet.vue +9 -4
- package/frontend-vue/layers/dms-ui/app/components/confirm/ConfirmModal.vue +9 -6
- package/frontend-vue/layers/dms-ui/app/components/flow-canvas/FlowCanvas.vue +16 -18
- package/frontend-vue/layers/dms-ui/app/components/form/FormBlock.vue +4 -9
- package/frontend-vue/layers/dms-ui/app/components/form/LocalizedField.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputAddress.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputImage.vue +5 -8
- package/frontend-vue/layers/dms-ui/app/components/form/components/RichText.vue +3 -2
- package/frontend-vue/layers/dms-ui/app/components/master-detail/MasterDetail.vue +3 -1
- package/frontend-vue/layers/dms-ui/app/components/period/usePeriodSelectorInteraction.ts +9 -7
- package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanBoard.vue +11 -6
- package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanDisplay.vue +40 -3
- package/frontend-vue/layers/dms-ui/app/composables/chart/apexDatetimeBuckets.ts +9 -5
- package/frontend-vue/layers/dms-ui/app/composables/chart/events.ts +6 -3
- package/frontend-vue/layers/dms-ui/app/composables/chart/heatmapColors.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/chart/localizeSeries.ts +13 -2
- package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +27 -4
- package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.types.ts +3 -2
- package/frontend-vue/layers/dms-ui/app/composables/chart/useChartFetch.ts +3 -4
- package/frontend-vue/layers/dms-ui/app/composables/confirm/types.ts +5 -1
- package/frontend-vue/layers/dms-ui/app/composables/containers/openDynamicContainer.ts +6 -6
- package/frontend-vue/layers/dms-ui/app/composables/containers/types.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/containers/useDrawer.ts +8 -5
- package/frontend-vue/layers/dms-ui/app/composables/containers/useModal.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/form/types/props.ts +5 -2
- package/frontend-vue/layers/dms-ui/app/composables/form/useForm.ts +80 -39
- package/frontend-vue/layers/dms-ui/app/composables/live/usePageLiveRefresh.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/resolveDmsComponent.ts +9 -2
- package/frontend-vue/layers/dms-ui/app/composables/tab/useTab.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/composables/table-view/shortcuts/tableViewShiftA.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/action-target.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/column.ts +3 -1
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/display.ts +6 -2
- package/frontend-vue/layers/dms-ui/app/composables/table-view/useTableViewExport.ts +6 -5
- package/frontend-vue/layers/dms-ui/app/composables/unsaved-changes/useUnsavedChanges.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/useExportJob.ts +21 -9
- package/frontend-vue/layers/dms-ui/app/utils/blockRefresh.ts +8 -2
- package/frontend-vue/layers/dms-ui/app/utils/cascader.ts +18 -8
- package/frontend-vue/layers/dms-ui/app/utils/metadataRetry.ts +1 -1
- package/frontend-vue/package.json +2 -1
- package/frontend-vue/scripts/check-api-error-presentation.mjs +257 -117
- package/frontend-vue/scripts/check-autoimport-boundaries.mjs +143 -27
- package/frontend-vue/scripts/check-disable-blocks.mjs +26 -4
- package/frontend-vue/scripts/check-dms-components.mjs +152 -246
- package/frontend-vue/scripts/check-invariants.mjs +100 -42
- package/frontend-vue/scripts/check-page-invariants.mjs +103 -40
- package/frontend-vue/scripts/dms-components-dependencies.mjs +106 -13
- package/frontend-vue/scripts/dms-components-script.mjs +375 -0
- package/frontend-vue/scripts/eslint-test-quality.mjs +126 -0
- package/frontend-vue/scripts/jsconfig.json +10 -0
- package/frontend-vue/scripts/probes/capture-frontend-probe.cjs +4 -2
- package/frontend-vue/scripts/probes/frontend-behavior.cjs +217 -47
- package/frontend-vue/scripts/probes/frontend-legacy.cjs +159 -8
- package/frontend-vue/scripts/probes/frontend-probe-controls.cjs +89 -10
- package/frontend-vue/scripts/prove-comment-emit.mjs +33 -4
- package/frontend-vue/scripts/prove-component-registration.mjs +110 -24
- package/frontend-vue/scripts/test-autoimport-boundaries.mjs +37 -6
- package/frontend-vue/scripts/test-dms-components.mjs +51 -2
- package/package.json +1 -1
- package/frontend-vue/eslint-test-quality.mjs +0 -62
|
@@ -7,6 +7,27 @@ import {
|
|
|
7
7
|
RENDERER,
|
|
8
8
|
rendererComponentNames,
|
|
9
9
|
} from "./dms-components-dependencies.mjs";
|
|
10
|
+
import {
|
|
11
|
+
layerPrefix,
|
|
12
|
+
parseScript,
|
|
13
|
+
scriptBindings,
|
|
14
|
+
scriptStrings,
|
|
15
|
+
} from "./dms-components-script.mjs";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {import("./dms-components-dependencies.mjs").DmsComponentsTools} Tools
|
|
19
|
+
* @typedef {import("../../checks/dms-components.mjs").DmsComponentsOptions} DmsComponentsOptions
|
|
20
|
+
* @typedef {import("./dms-components-script.mjs").UseKind} UseKind
|
|
21
|
+
* @typedef {{ kind: UseKind, name: string, unprefixed?: boolean, file: string, line: number }} Use
|
|
22
|
+
* @typedef {{ file: string, source: string }} SourceText
|
|
23
|
+
* @typedef {{ tags: Set<string>, components: Set<string>, layouts: Set<string> }} KnownNames
|
|
24
|
+
* @typedef {import("vue/compiler-sfc").SFCTemplateBlock["ast"]} TemplateRoot
|
|
25
|
+
* @typedef {NonNullable<TemplateRoot> | NonNullable<TemplateRoot>["children"][number]} TemplateNode
|
|
26
|
+
* @typedef {Extract<TemplateNode, { tagType: unknown }>} TemplateElement
|
|
27
|
+
* @typedef {TemplateElement["props"][number]} TemplateProp
|
|
28
|
+
* @typedef {Extract<TemplateProp, { value: unknown }>} TemplateAttribute
|
|
29
|
+
* @typedef {TemplateAttribute & { value: NonNullable<TemplateAttribute["value"]> }} StaticAttribute
|
|
30
|
+
*/
|
|
10
31
|
|
|
11
32
|
const DMS_PREFIX = "Dms";
|
|
12
33
|
const DMS_LAYERS = fileURLToPath(new URL("../layers", import.meta.url));
|
|
@@ -27,14 +48,23 @@ const UNREGISTERED_DMS_FILES = new Set([
|
|
|
27
48
|
"dms-ui/app/build/components/table/TableBody.vue",
|
|
28
49
|
]);
|
|
29
50
|
|
|
30
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The second names dms.frontend.ts registers some components under.
|
|
53
|
+
*
|
|
54
|
+
* @type {Readonly<Record<string, string>>}
|
|
55
|
+
*/
|
|
31
56
|
const DMS_ALIASES = {
|
|
32
57
|
ActivityFeed: "ActivityFeedBlock",
|
|
33
58
|
SectionPanel: "SectionBlock",
|
|
34
59
|
FieldRow: "FieldRowBlock",
|
|
35
60
|
};
|
|
36
61
|
|
|
37
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* A file path as dms.frontend.ts names its component: `notice-banner.vue` is `NoticeBanner`.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} name
|
|
66
|
+
* @returns {string}
|
|
67
|
+
*/
|
|
38
68
|
function pascalCase(name) {
|
|
39
69
|
return name
|
|
40
70
|
.replace(/\.vue$/, "")
|
|
@@ -44,13 +74,31 @@ function pascalCase(name) {
|
|
|
44
74
|
.join("");
|
|
45
75
|
}
|
|
46
76
|
|
|
47
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* The last name Vue's `resolveComponent` tries for a tag: `dms-card-panel` is `DmsCardPanel`.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} name
|
|
81
|
+
* @returns {string}
|
|
82
|
+
*/
|
|
48
83
|
function vueName(name) {
|
|
49
|
-
const camel = name.replace(
|
|
84
|
+
const camel = name.replace(
|
|
85
|
+
/-(\w)/g,
|
|
86
|
+
/**
|
|
87
|
+
* @param {string} _
|
|
88
|
+
* @param {string} letter
|
|
89
|
+
* @returns {string}
|
|
90
|
+
*/
|
|
91
|
+
(_, letter) => letter.toUpperCase(),
|
|
92
|
+
);
|
|
50
93
|
return `${camel.charAt(0).toUpperCase()}${camel.slice(1)}`;
|
|
51
94
|
}
|
|
52
95
|
|
|
53
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* A component name as the renderer's `resolveDmsComponent` compares it.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} name
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
54
102
|
function componentKey(name) {
|
|
55
103
|
return name
|
|
56
104
|
.replace(/^lazy/i, "")
|
|
@@ -58,7 +106,12 @@ function componentKey(name) {
|
|
|
58
106
|
.toLowerCase();
|
|
59
107
|
}
|
|
60
108
|
|
|
61
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* A layout name as the renderer's `registerLayout` compares it.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} name
|
|
113
|
+
* @returns {string}
|
|
114
|
+
*/
|
|
62
115
|
function layoutKey(name) {
|
|
63
116
|
return name
|
|
64
117
|
.replace(/^lazy/i, "")
|
|
@@ -67,6 +120,11 @@ function layoutKey(name) {
|
|
|
67
120
|
.toLowerCase();
|
|
68
121
|
}
|
|
69
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} root
|
|
125
|
+
* @param {(path: string) => boolean} keep
|
|
126
|
+
* @returns {string[]}
|
|
127
|
+
*/
|
|
70
128
|
function files(root, keep) {
|
|
71
129
|
if (!existsSync(root)) return [];
|
|
72
130
|
return readdirSync(root, { withFileTypes: true }).flatMap((entry) => {
|
|
@@ -83,6 +141,10 @@ function files(root, keep) {
|
|
|
83
141
|
* `app/components/` or `app/build/components/`, the path below
|
|
84
142
|
* `app/custom-pages/` of a custom page, the path below `app/custom-layouts/`
|
|
85
143
|
* of a layout.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} root
|
|
146
|
+
* @param {Set<string>} [skip]
|
|
147
|
+
* @returns {{ components: string[], layouts: string[] }}
|
|
86
148
|
*/
|
|
87
149
|
function registeredFiles(root, skip = new Set()) {
|
|
88
150
|
const components = [];
|
|
@@ -103,6 +165,8 @@ function registeredFiles(root, skip = new Set()) {
|
|
|
103
165
|
* The names the installed `@antelopejs/dms` registers, as its
|
|
104
166
|
* `dms.frontend.ts` does: each component with its `Dms` prefix and aliases,
|
|
105
167
|
* and each layout.
|
|
168
|
+
*
|
|
169
|
+
* @returns {{ components: Set<string>, layouts: Set<string> }}
|
|
106
170
|
*/
|
|
107
171
|
export function dmsRegistrations() {
|
|
108
172
|
const { components, layouts } = registeredFiles(
|
|
@@ -121,235 +185,70 @@ export function dmsRegistrations() {
|
|
|
121
185
|
};
|
|
122
186
|
}
|
|
123
187
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function unwrap(node, ts) {
|
|
135
|
-
let inner = node;
|
|
136
|
-
while (
|
|
137
|
-
ts.isParenthesizedExpression(inner) ||
|
|
138
|
-
ts.isAsExpression(inner) ||
|
|
139
|
-
ts.isSatisfiesExpression(inner) ||
|
|
140
|
-
ts.isNonNullExpression(inner) ||
|
|
141
|
-
ts.isTypeAssertionExpression(inner)
|
|
142
|
-
)
|
|
143
|
-
inner = inner.expression;
|
|
144
|
-
return inner;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function literalText(node, ts) {
|
|
148
|
-
return ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)
|
|
149
|
-
? node.text
|
|
150
|
-
: undefined;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function bindingNames(name, ts) {
|
|
154
|
-
if (ts.isIdentifier(name)) return [name.text];
|
|
155
|
-
return name.elements.flatMap((element) =>
|
|
156
|
-
ts.isOmittedExpression(element) ? [] : bindingNames(element.name, ts),
|
|
157
|
-
);
|
|
188
|
+
/**
|
|
189
|
+
* @param {string} source
|
|
190
|
+
* @param {number} offset
|
|
191
|
+
* @returns {number}
|
|
192
|
+
*/
|
|
193
|
+
function lineAt(source, offset) {
|
|
194
|
+
return source.slice(0, offset).split("\n").length;
|
|
158
195
|
}
|
|
159
196
|
|
|
160
197
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
198
|
+
* @param {TemplateNode} node
|
|
199
|
+
* @returns {node is TemplateElement}
|
|
163
200
|
*/
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
if (ts.isVariableStatement(statement))
|
|
167
|
-
for (const declaration of statement.declarationList.declarations) {
|
|
168
|
-
if (!bindingNames(declaration.name, ts).includes(name)) continue;
|
|
169
|
-
const constant =
|
|
170
|
-
statement.declarationList.flags & ts.NodeFlags.Const &&
|
|
171
|
-
ts.isIdentifier(declaration.name) &&
|
|
172
|
-
declaration.initializer;
|
|
173
|
-
return {
|
|
174
|
-
text: constant
|
|
175
|
-
? literalText(unwrap(declaration.initializer, ts), ts)
|
|
176
|
-
: undefined,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
const imported = ts.isImportDeclaration(statement)
|
|
180
|
-
? [
|
|
181
|
-
statement.importClause?.name,
|
|
182
|
-
...(statement.importClause?.namedBindings?.elements ?? []),
|
|
183
|
-
]
|
|
184
|
-
: [statement.name];
|
|
185
|
-
if (
|
|
186
|
-
imported.some((binding) => nameOf(binding?.name ?? binding, ts) === name)
|
|
187
|
-
)
|
|
188
|
-
return {};
|
|
189
|
-
}
|
|
190
|
-
return undefined;
|
|
201
|
+
function isElement(node) {
|
|
202
|
+
return node.type === ELEMENT;
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
...(ts.isCatchClause(scope) && scope.variableDeclaration
|
|
204
|
-
? [scope.variableDeclaration]
|
|
205
|
-
: []),
|
|
206
|
-
];
|
|
207
|
-
return declarations.some((declaration) =>
|
|
208
|
-
bindingNames(declaration.name, ts).includes(name),
|
|
205
|
+
/**
|
|
206
|
+
* @param {TemplateProp} prop
|
|
207
|
+
* @returns {prop is StaticAttribute}
|
|
208
|
+
*/
|
|
209
|
+
function isStaticIs(prop) {
|
|
210
|
+
return (
|
|
211
|
+
prop.type === ATTRIBUTE &&
|
|
212
|
+
"value" in prop &&
|
|
213
|
+
prop.name === "is" &&
|
|
214
|
+
Boolean(prop.value)
|
|
209
215
|
);
|
|
210
216
|
}
|
|
211
217
|
|
|
212
|
-
/** The string the `const` that `identifier` refers to holds, when the nearest declaration of its name is one. */
|
|
213
|
-
function constantFor(identifier, ts) {
|
|
214
|
-
for (let scope = identifier.parent; scope; scope = scope.parent) {
|
|
215
|
-
if (shadows(scope, identifier.text, ts)) return undefined;
|
|
216
|
-
if (
|
|
217
|
-
ts.isBlock(scope) ||
|
|
218
|
-
ts.isSourceFile(scope) ||
|
|
219
|
-
ts.isModuleBlock(scope)
|
|
220
|
-
) {
|
|
221
|
-
const declared = declaredIn(scope.statements, identifier.text, ts);
|
|
222
|
-
if (declared) return declared.text;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return undefined;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** A string literal, or a `const` of the same file in scope holding one. */
|
|
229
|
-
function stringOf(node, ts) {
|
|
230
|
-
if (!node) return undefined;
|
|
231
|
-
const value = unwrap(node, ts);
|
|
232
|
-
return ts.isIdentifier(value)
|
|
233
|
-
? constantFor(value, ts)
|
|
234
|
-
: literalText(value, ts);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function nameOf(node, ts) {
|
|
238
|
-
if (!node) return undefined;
|
|
239
|
-
if (ts.isIdentifier(node) || ts.isStringLiteral(node)) return node.text;
|
|
240
|
-
if (ts.isPropertyAccessExpression(node)) return node.name.text;
|
|
241
|
-
return undefined;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function isBanner(object, ts) {
|
|
245
|
-
const keys = new Set(object.properties.map((p) => nameOf(p.name, ts)));
|
|
246
|
-
return keys.has("key") && keys.has("variant");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
218
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* ComponentBuilder`, a `componentName` property, a layout banner's
|
|
253
|
-
* `component`), or one the layer registers.
|
|
219
|
+
* @param {TemplateNode} node
|
|
220
|
+
* @returns {TemplateNode[]}
|
|
254
221
|
*/
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
callee === "CustomComponent" ||
|
|
263
|
-
(callee === "ComponentBuilder" && ts.isNewExpression(node))
|
|
264
|
-
)
|
|
265
|
-
return { kind: "builder", node: argument };
|
|
266
|
-
if (callee === "registerComponent" || callee === "registerLayout")
|
|
267
|
-
return { kind: callee, node: argument, unprefixed: unprefixed(node, ts) };
|
|
268
|
-
if (ts.isShorthandPropertyAssignment(node))
|
|
269
|
-
return nameOf(node.name, ts) === "componentName"
|
|
270
|
-
? { kind: "componentName", node: node.name }
|
|
271
|
-
: undefined;
|
|
272
|
-
if (!ts.isPropertyAssignment(node)) return undefined;
|
|
273
|
-
const property = nameOf(node.name, ts);
|
|
274
|
-
if (property === "componentName")
|
|
275
|
-
return { kind: "componentName", node: node.initializer };
|
|
276
|
-
return property === "component" && isBanner(node.parent, ts)
|
|
277
|
-
? { kind: "builder", node: node.initializer }
|
|
278
|
-
: undefined;
|
|
222
|
+
function childrenOf(node) {
|
|
223
|
+
/** @type {TemplateNode[]} */
|
|
224
|
+
const children = [];
|
|
225
|
+
if ("children" in node)
|
|
226
|
+
for (const child of node.children)
|
|
227
|
+
if (isTemplateNode(child)) children.push(child);
|
|
228
|
+
return children;
|
|
279
229
|
}
|
|
280
230
|
|
|
281
|
-
/**
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
property.initializer.kind === ts.SyntaxKind.FalseKeyword,
|
|
292
|
-
),
|
|
231
|
+
/**
|
|
232
|
+
* @param {unknown} value
|
|
233
|
+
* @returns {value is TemplateNode}
|
|
234
|
+
*/
|
|
235
|
+
function isTemplateNode(value) {
|
|
236
|
+
return (
|
|
237
|
+
typeof value === "object" &&
|
|
238
|
+
value !== null &&
|
|
239
|
+
"type" in value &&
|
|
240
|
+
typeof value.type === "number"
|
|
293
241
|
);
|
|
294
242
|
}
|
|
295
243
|
|
|
296
|
-
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const named = namedString(node, ts);
|
|
301
|
-
const name = named && stringOf(named.node, ts);
|
|
302
|
-
if (name)
|
|
303
|
-
found.push({
|
|
304
|
-
kind: named.kind,
|
|
305
|
-
name,
|
|
306
|
-
unprefixed: named.unprefixed,
|
|
307
|
-
offset: named.node.getStart(tree),
|
|
308
|
-
});
|
|
309
|
-
ts.forEachChild(node, visit);
|
|
310
|
-
};
|
|
311
|
-
visit(tree);
|
|
312
|
-
return found;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function lineAt(source, offset) {
|
|
316
|
-
return source.slice(0, offset).split("\n").length;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/** The names a script declares at its top level, which its template may use as tags. */
|
|
320
|
-
function scriptBindings(tree, ts) {
|
|
321
|
-
return tree.statements.flatMap((statement) => {
|
|
322
|
-
if (ts.isImportDeclaration(statement)) {
|
|
323
|
-
const clause = statement.importClause;
|
|
324
|
-
if (!clause || clause.isTypeOnly) return [];
|
|
325
|
-
const named = clause.namedBindings;
|
|
326
|
-
return [
|
|
327
|
-
...(clause.name ? [clause.name.text] : []),
|
|
328
|
-
...(named && ts.isNamedImports(named)
|
|
329
|
-
? named.elements
|
|
330
|
-
.filter((element) => !element.isTypeOnly)
|
|
331
|
-
.map((element) => element.name.text)
|
|
332
|
-
: []),
|
|
333
|
-
];
|
|
334
|
-
}
|
|
335
|
-
if (ts.isVariableStatement(statement))
|
|
336
|
-
return statement.declarationList.declarations.flatMap((declaration) =>
|
|
337
|
-
bindingNames(declaration.name, ts),
|
|
338
|
-
);
|
|
339
|
-
return (ts.isFunctionDeclaration(statement) ||
|
|
340
|
-
ts.isClassDeclaration(statement)) &&
|
|
341
|
-
statement.name
|
|
342
|
-
? [statement.name.text]
|
|
343
|
-
: [];
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
|
|
244
|
+
/**
|
|
245
|
+
* @param {TemplateNode} node
|
|
246
|
+
* @returns {{ kind: "vue", name: string, line: number }[]}
|
|
247
|
+
*/
|
|
347
248
|
function templateUses(node) {
|
|
348
|
-
const children = (node
|
|
349
|
-
if (node
|
|
350
|
-
const is = node.props.find(
|
|
351
|
-
(prop) => prop.type === ATTRIBUTE && prop.name === "is" && prop.value,
|
|
352
|
-
);
|
|
249
|
+
const children = childrenOf(node).flatMap(templateUses);
|
|
250
|
+
if (!isElement(node)) return children;
|
|
251
|
+
const is = node.props.find(isStaticIs);
|
|
353
252
|
const tag = node.tagType === COMPONENT_TAG ? node.tag : undefined;
|
|
354
253
|
const name = node.tag === "component" ? is?.value.content : tag;
|
|
355
254
|
return name
|
|
@@ -357,7 +256,13 @@ function templateUses(node) {
|
|
|
357
256
|
: children;
|
|
358
257
|
}
|
|
359
258
|
|
|
360
|
-
/**
|
|
259
|
+
/**
|
|
260
|
+
* What one source file names by string or tag, with the line of each.
|
|
261
|
+
*
|
|
262
|
+
* @param {SourceText} sourceText
|
|
263
|
+
* @param {Tools} tools
|
|
264
|
+
* @returns {Use[]}
|
|
265
|
+
*/
|
|
361
266
|
function fileStrings({ file, source }, tools) {
|
|
362
267
|
if (!file.endsWith(".vue"))
|
|
363
268
|
return scriptStrings(parseScript(file, source, tools.ts), tools.ts).map(
|
|
@@ -367,7 +272,7 @@ function fileStrings({ file, source }, tools) {
|
|
|
367
272
|
if (errors.length)
|
|
368
273
|
throw new Error(`Cannot parse ${file}: ${errors.join(", ")}`);
|
|
369
274
|
const scripts = [descriptor.script, descriptor.scriptSetup]
|
|
370
|
-
.filter(
|
|
275
|
+
.filter((block) => block !== null && block !== undefined)
|
|
371
276
|
.map((block) => ({
|
|
372
277
|
block,
|
|
373
278
|
tree: parseScript(file, block.content, tools.ts),
|
|
@@ -393,32 +298,10 @@ function fileStrings({ file, source }, tools) {
|
|
|
393
298
|
}
|
|
394
299
|
|
|
395
300
|
/**
|
|
396
|
-
*
|
|
397
|
-
*
|
|
301
|
+
* @param {string[]} roots
|
|
302
|
+
* @param {RegExp} pattern
|
|
303
|
+
* @returns {SourceText[]}
|
|
398
304
|
*/
|
|
399
|
-
function layerPrefix(layer, ts) {
|
|
400
|
-
const entry = join(layer, "dms.frontend.ts");
|
|
401
|
-
if (!existsSync(entry)) return "";
|
|
402
|
-
const tree = parseScript(entry, readFileSync(entry, "utf8"), ts);
|
|
403
|
-
const declared = [];
|
|
404
|
-
const visit = (node) => {
|
|
405
|
-
if (
|
|
406
|
-
(ts.isPropertyAssignment(node) ||
|
|
407
|
-
ts.isShorthandPropertyAssignment(node)) &&
|
|
408
|
-
nameOf(node.name, ts) === "componentPrefix"
|
|
409
|
-
)
|
|
410
|
-
declared.push(stringOf(node.initializer ?? node.name, ts));
|
|
411
|
-
ts.forEachChild(node, visit);
|
|
412
|
-
};
|
|
413
|
-
visit(tree);
|
|
414
|
-
const prefix = declared.find((value) => value !== undefined);
|
|
415
|
-
if (declared.length && prefix === undefined)
|
|
416
|
-
throw new Error(
|
|
417
|
-
`${entry}: write componentPrefix as a string, or a const of that file holding one, so that the DMS component check reads it`,
|
|
418
|
-
);
|
|
419
|
-
return prefix ?? "";
|
|
420
|
-
}
|
|
421
|
-
|
|
422
305
|
function readSources(roots, pattern) {
|
|
423
306
|
return roots
|
|
424
307
|
.flatMap((root) => {
|
|
@@ -430,11 +313,19 @@ function readSources(roots, pattern) {
|
|
|
430
313
|
.map((file) => ({ file, source: readFileSync(file, "utf8") }));
|
|
431
314
|
}
|
|
432
315
|
|
|
433
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* The names Vue and the renderer resolve, from dms, the renderer and the layer.
|
|
318
|
+
*
|
|
319
|
+
* @param {string} root
|
|
320
|
+
* @param {Use[]} layerStrings
|
|
321
|
+
* @param {Tools} tools
|
|
322
|
+
* @returns {Promise<KnownNames>}
|
|
323
|
+
*/
|
|
434
324
|
async function knownNames(root, layerStrings, tools) {
|
|
435
325
|
const dms = dmsRegistrations();
|
|
436
326
|
const prefix = layerPrefix(root, tools.ts);
|
|
437
327
|
const own = registeredFiles(root);
|
|
328
|
+
/** @param {UseKind} kind */
|
|
438
329
|
const registered = (kind) => layerStrings.filter((use) => use.kind === kind);
|
|
439
330
|
const tags = new Set([
|
|
440
331
|
...dms.components,
|
|
@@ -457,6 +348,11 @@ async function knownNames(root, layerStrings, tools) {
|
|
|
457
348
|
};
|
|
458
349
|
}
|
|
459
350
|
|
|
351
|
+
/**
|
|
352
|
+
* @param {Pick<Use, "kind" | "name">} use
|
|
353
|
+
* @param {KnownNames} known
|
|
354
|
+
* @returns {boolean}
|
|
355
|
+
*/
|
|
460
356
|
function isKnown({ kind, name }, known) {
|
|
461
357
|
if (kind === "vue")
|
|
462
358
|
return known.tags.has(name) || known.tags.has(vueName(name));
|
|
@@ -474,11 +370,18 @@ function isKnown({ kind, name }, known) {
|
|
|
474
370
|
* the layer or in `sources` (the module's backend directories). Vue renders
|
|
475
371
|
* an unknown tag as an empty element, with no error. Each diagnostic names
|
|
476
372
|
* the file, the line and the name.
|
|
373
|
+
*
|
|
374
|
+
* @param {DmsComponentsOptions} options
|
|
375
|
+
* @returns {Promise<string[]>}
|
|
477
376
|
*/
|
|
478
377
|
export async function checkDmsComponents(options) {
|
|
479
378
|
return (await inspect(options)).diagnostics;
|
|
480
379
|
}
|
|
481
380
|
|
|
381
|
+
/**
|
|
382
|
+
* @param {DmsComponentsOptions} options
|
|
383
|
+
* @returns {Promise<{ diagnostics: string[], root: string, rendererMissing: boolean }>}
|
|
384
|
+
*/
|
|
482
385
|
async function inspect({ layer, sources = [] }) {
|
|
483
386
|
const root = resolve(layer);
|
|
484
387
|
const tools = dependencies(root);
|
|
@@ -506,6 +409,9 @@ async function inspect({ layer, sources = [] }) {
|
|
|
506
409
|
* Rejects with every diagnostic of {@link checkDmsComponents}, one per line.
|
|
507
410
|
* When `@antelopejs/dms-frontend` is not installed, the last line says that
|
|
508
411
|
* the components its renderer registers count as unknown, and how to add it.
|
|
412
|
+
*
|
|
413
|
+
* @param {DmsComponentsOptions} options
|
|
414
|
+
* @returns {Promise<void>}
|
|
509
415
|
*/
|
|
510
416
|
export async function assertDmsComponents(options) {
|
|
511
417
|
const { diagnostics, root, rendererMissing } = await inspect(options);
|