@antelopejs/dms 0.20.7 → 0.20.8-next.919.g0c68f67

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 (74) hide show
  1. package/bin/control/commands-verify.mjs +8 -49
  2. package/bin/control/options.mjs +0 -1
  3. package/bin/control/run-state.mjs +1 -1
  4. package/bin/control/timing.mjs +1 -16
  5. package/bin/control/timing.test.mjs +0 -11
  6. package/bin/control/verify/decode.mjs +4 -144
  7. package/bin/control/verify/decode.test.mjs +1 -149
  8. package/bin/control/verify/formal.mjs +22 -218
  9. package/bin/control/verify/formal.test.mjs +60 -117
  10. package/bin/control/verify/map.test.mjs +0 -73
  11. package/bin/control/verify/types.mjs +4 -18
  12. package/bin/dms-control.mjs +0 -2
  13. package/dist/implementations/dms/page/controller.d.ts +2 -1
  14. package/dist/implementations/dms/page/controller.js.map +1 -1
  15. package/dist/implementations/dms-builder/engine/connection-access-config.js +2 -2
  16. package/dist/implementations/dms-builder/engine/connection-targets.js.map +1 -1
  17. package/dist/implementations/dms-builder/engine/database-access.d.ts +1 -1
  18. package/dist/implementations/dms-builder/engine/database-access.js +2 -2
  19. package/dist/implementations/dms-builder/engine/database-check-input.d.ts +3 -2
  20. package/dist/implementations/dms-builder/engine/database-check-input.js.map +1 -1
  21. package/dist/implementations/dms-builder/engine/database-check.js +2 -2
  22. package/dist/implementations/dms-builder/engine/database-check.js.map +1 -1
  23. package/dist/implementations/dms-builder/engine/probe-answer.d.ts +44 -1
  24. package/dist/implementations/dms-builder/engine/probe-answer.js +2 -5
  25. package/dist/implementations/dms-builder/engine/probe-answer.js.map +1 -1
  26. package/dist/mockup/files.d.ts +1 -1
  27. package/dist/mockup/files.js +2 -2
  28. package/dist/pages/settings/users/roles.js.map +1 -1
  29. package/dist/store/internal/frontend/frontend-ready.d.ts +2 -1
  30. package/dist/store/internal/frontend/frontend-ready.js.map +1 -1
  31. package/dist/store/operations.js +4 -4
  32. package/dist/store/operations.js.map +1 -1
  33. package/dist/utils/upload-constraints.d.ts +1 -1
  34. package/dist/utils/upload-constraints.js +2 -2
  35. package/dist/utils/upload-constraints.js.map +1 -1
  36. package/dist/validation/issue-message.d.ts +1 -1
  37. package/dist/validation/issue-message.js +3 -3
  38. package/dist/validation/issue-message.js.map +1 -1
  39. package/frontend-vue/layers/dms-core/app/utils/formatter.ts +1 -0
  40. package/frontend-vue/layers/dms-layout/app/build/composables/navigation/useVisitNavBadges.ts +11 -14
  41. package/frontend-vue/layers/dms-layout/app/build/composables/settings/security/useSecurityFormat.ts +5 -5
  42. package/frontend-vue/layers/dms-layout/app/build/utils/modules-catalog.ts +7 -2
  43. package/frontend-vue/layers/dms-layout/app/build/utils/notificationPayload.ts +9 -5
  44. package/frontend-vue/layers/dms-layout/app/composables/page/useModuleHistory.ts +4 -1
  45. package/frontend-vue/layers/dms-layout/app/composables/page/useModulesListing.ts +7 -17
  46. package/frontend-vue/layers/dms-layout/app/custom-pages/modules.vue +5 -1
  47. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupCatalog.ts +4 -1
  48. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSpec.ts +18 -16
  49. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePreviewFrame.ts +2 -1
  50. package/frontend-vue/layers/dms-ui/app/build/composables/containers/drawerSize.ts +4 -4
  51. package/frontend-vue/layers/dms-ui/app/build/composables/data-types/relationBadges.ts +2 -5
  52. package/frontend-vue/layers/dms-ui/app/build/composables/form/fieldComponentProps.ts +2 -2
  53. package/frontend-vue/layers/dms-ui/app/build/composables/layout/sidePanelState.ts +5 -2
  54. package/frontend-vue/layers/dms-ui/app/build/composables/period/periodQuery.ts +6 -3
  55. package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableRowActionValues.ts +13 -13
  56. package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/writeError.ts +2 -2
  57. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +1 -1
  58. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +26 -18
  59. package/frontend-vue/layers/dms-ui/app/build/utils/mockupCatalog.ts +7 -2
  60. package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +2 -1
  61. package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +2 -0
  62. package/frontend-vue/layers/dms-ui/app/composables/useExportJob.ts +2 -2
  63. package/package.json +9 -8
  64. package/bin/control/verify/behaviour.mjs +0 -183
  65. package/bin/control/verify/behaviour.test.mjs +0 -472
  66. package/bin/control/verify/emit.mjs +0 -539
  67. package/bin/control/verify/judgement.mjs +0 -101
  68. package/bin/control/verify/verdict.mjs +0 -327
  69. package/frontend-vue/scripts/probes/capture-frontend-probe.cjs +0 -23
  70. package/frontend-vue/scripts/probes/frontend-behavior.cjs +0 -606
  71. package/frontend-vue/scripts/probes/frontend-legacy.cjs +0 -620
  72. package/frontend-vue/scripts/probes/frontend-probe-controls.cjs +0 -322
  73. package/frontend-vue/scripts/prove-comment-emit.mjs +0 -171
  74. package/frontend-vue/scripts/prove-component-registration.mjs +0 -259
@@ -1,620 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("node:fs");
4
- const path = require("node:path");
5
- const vm = require("node:vm");
6
- const { createRequire } = require("node:module");
7
-
8
- const root = path.resolve(process.argv[2]);
9
- const frontend = path.join(root, "packages/dms/frontend-vue");
10
-
11
- /**
12
- * @typedef {Omit<typeof import("@vue/compiler-sfc"), "registerTS"> & {
13
- * registerTS: (load: () => typeof import("typescript")) => void;
14
- * }} CompilerSfc
15
- */
16
-
17
- /**
18
- * @typedef {{
19
- * (id: "typescript"): typeof import("typescript");
20
- * (id: "@vue/compiler-sfc"): CompilerSfc;
21
- * (id: "vue"): {
22
- * mergeDefaults: (raw: unknown, defaults: unknown) => unknown;
23
- * mergeModels: (first: unknown, second: unknown) => unknown;
24
- * };
25
- * (id: "vite"): typeof import("vite");
26
- * (id: "node:path"): typeof import("node:path");
27
- * }} FrontendRequire
28
- */
29
-
30
- /** @type {FrontendRequire} */
31
- const req = createRequire(path.join(frontend, "package.json"));
32
- const ts = {
33
- ...req("typescript"),
34
- findConfigFile: () => path.join(root, ".dependency-cruiser.tsconfig.json"),
35
- };
36
- const sfc = req("@vue/compiler-sfc");
37
- sfc.registerTS(() => ts);
38
- const layers = path.join(frontend, "layers");
39
- const componentManifest = {
40
- "dms-auth/app/components/": ["OAuthButtons.vue"],
41
- "dms-auth/app/custom-pages/auth/": [
42
- "2fa.vue",
43
- "backup.vue",
44
- "forgot-validation.vue",
45
- "login.vue",
46
- "oauth-complete.vue",
47
- "signup.vue",
48
- "validate.vue",
49
- ],
50
- "dms-layout/app/build/components/": [
51
- "layout/DashboardHeader.vue",
52
- "layout/DashboardSidePanel.vue",
53
- "layout/DashboardSidebar.vue",
54
- "layout/LayoutFooter.vue",
55
- "layout/PageHeaderActionBar.vue",
56
- "notification/NotificationPopover.vue",
57
- "pages/modules/ModuleStoreDependencyPicker.vue",
58
- "pages/modules/ModuleStoreOperation.vue",
59
- "pages/modules/ModuleTile.vue",
60
- "pages/settings/members/MemberRolePicker.vue",
61
- "pages/settings/notification/NotificationInboxDisplay.vue",
62
- "pages/settings/profile/ProfilePersonalInfo.vue",
63
- "pages/settings/profile/ProfileSummaryRow.vue",
64
- "pages/settings/roles/RolePanelHead.vue",
65
- "pages/settings/security/SecurityEditPanel.vue",
66
- "pages/settings/security/SecurityEmail.vue",
67
- "pages/settings/security/SecurityPanelField.vue",
68
- "pages/settings/security/SecuritySessions.vue",
69
- "pages/settings/security/SecurityStatus.vue",
70
- "pages/settings/security/SecurityTwoFactor.vue",
71
- "pages/settings/theme/CssVariablesList.vue",
72
- "pages/settings/theme/ThemePreview.vue",
73
- ],
74
- "dms-layout/app/components/": [
75
- "navigation/AccordionItemSync.vue",
76
- "navigation/NavigationMenu.vue",
77
- ],
78
- "dms-layout/app/custom-pages/settings/": ["roles.vue", "shortcuts.vue"],
79
- "dms-layout/app/emails/components/": ["EmailLayout.vue"],
80
- "dms-layout/app/": ["error.vue"],
81
- "dms-layout/app/pages/": ["[...slug].vue"],
82
- "dms-onboarding/app/build/components/": [
83
- "onboarding/StepIndicator.vue",
84
- "onboarding/steps/StepReady.vue",
85
- ],
86
- "dms-ui/app/build/components/": [
87
- "blocks/BlockActions.vue",
88
- "containers/drawer/DynamicDrawer.vue",
89
- "containers/modal/DynamicModal.vue",
90
- "containers/row/RowHeader.vue",
91
- "form/FormFieldControl.vue",
92
- "form/FormFieldNotes.vue",
93
- "form/PasswordInput.vue",
94
- "period/PeriodRangeCalendar.vue",
95
- "sortable/SortableList.vue",
96
- "stat/StatCell.vue",
97
- "table-view/CardAvatar.vue",
98
- "table-view/CardsDisplay.vue",
99
- "table-view/ExpandedRowDetail.vue",
100
- "table-view/IdentityCell.vue",
101
- "table-view/LiveHoldBanner.vue",
102
- "table/TableActions.vue",
103
- "table/FiltersRow.vue",
104
- "table/TableMenu.vue",
105
- "table/MenuColumns.vue",
106
- "table/MenuDensity.vue",
107
- "table/MenuFilter.vue",
108
- "table/MenuImport.vue",
109
- "table/MenuPage.vue",
110
- "table/MenuRoot.vue",
111
- "table/MenuSort.vue",
112
- "table/MenuViewMode.vue",
113
- "table/TablePagination.vue",
114
- "table/RowSelection.vue",
115
- "table/TableRoot.vue",
116
- "table/TableTabs.vue",
117
- "table/TableViews.vue",
118
- ],
119
- "dms-ui/app/components/": `
120
- PasswordStrength.vue RecursiveComponent.vue activity/ActivityItem.vue
121
- banner/NoticeBanner.vue block-preview/BlockPreview.vue blocks/BannerBlock.vue
122
- blocks/CardBlock.vue blocks/KeyValueListBlock.vue blocks/LiveToggleBlock.vue
123
- card/CardPanel.vue card/NavCard.vue chart/ApexChartHost.vue chart/ChartBlock.vue
124
- chart/internal/SparklineChart.vue check-list/CheckList.vue check-list/PasswordRules.vue
125
- code-snippet/CodeSnippet.vue confirm/ConfirmModal.vue empty-state/EmptyState.vue
126
- field-row/FieldRow.vue flow-canvas/FlowCanvas.vue form/FormBlock.vue form/LocalizedField.vue
127
- icon-well/IconWell.vue key-value-list/KeyValueList.vue link/AutoLink.vue
128
- list-row/ListRow.vue master-detail/MasterDetail.vue meter/MeterBar.vue meter/MeterBlock.vue
129
- period/PeriodSelector.vue record-card/RecordCard.vue section-header/EyebrowLabel.vue
130
- section-header/SectionHeader.vue section/SectionPanel.vue segmented/SegmentedControl.vue
131
- stat-group/StatGroup.vue status-pill/StatusPill.vue tab/TabBlock.vue
132
- table-view/CascaderPath.vue table-view/KanbanBoard.vue table-view/KanbanDisplay.vue
133
- table-view/TableView.vue top-list/TopListCard.vue
134
- `
135
- .trim()
136
- .split(/\s+/),
137
- "dms-ui/app/components/form/components/": [
138
- "InputCalendar.vue",
139
- "InputCascader.vue",
140
- "ChoiceCards.vue",
141
- "DatePicker.vue",
142
- "DatePickerRange.vue",
143
- "DisplayValue.vue",
144
- "InputFile.vue",
145
- "InputImage.vue",
146
- "InputAddress.vue",
147
- "InputColor.vue",
148
- "InputNumber.vue",
149
- "InputPercentage.vue",
150
- "InputTags.vue",
151
- "KeyValue.vue",
152
- "InputRepeater.vue",
153
- "RepeaterTable.vue",
154
- "RichText.vue",
155
- ],
156
- };
157
- const compilerOptions = {
158
- module: ts.ModuleKind.CommonJS,
159
- target: ts.ScriptTarget.ES2022,
160
- };
161
-
162
- /** @type {Record<string, () => unknown>} */
163
- const dependencyLoaders = {
164
- "node:path": () => req("node:path"),
165
- vite: () => req("vite"),
166
- };
167
-
168
- /** @typedef {Record<string, unknown>} ProbeBindings */
169
-
170
- /**
171
- * Runs one transpiled source in a fresh context and returns its exports. The
172
- * exports follow the file, so each caller binds the type of the file it loads.
173
- * @param {string} source
174
- * @param {string} filename
175
- * @param {ProbeBindings} [globals]
176
- * @param {ProbeBindings} [imports]
177
- * @param {import("typescript").CustomTransformers} [transformers]
178
- * @returns {any}
179
- */
180
- function evaluate(source, filename, globals = {}, imports = {}, transformers) {
181
- const module = { exports: {} };
182
- /**
183
- * @param {string} specifier
184
- * @returns {unknown}
185
- */
186
- const localRequire = (specifier) => {
187
- if (specifier in imports) return imports[specifier];
188
- if (specifier.startsWith(".")) {
189
- const target = path.resolve(path.dirname(filename), specifier);
190
- return load(target.endsWith(".ts") ? target : `${target}.ts`, globals);
191
- }
192
- const loader = dependencyLoaders[specifier];
193
- if (!loader) throw new Error(`Unexpected probe dependency ${specifier}`);
194
- return loader();
195
- };
196
- const code = ts.transpileModule(source, {
197
- compilerOptions,
198
- fileName: filename,
199
- transformers,
200
- }).outputText;
201
- vm.runInNewContext(
202
- code,
203
- {
204
- module,
205
- exports: module.exports,
206
- require: localRequire,
207
- Headers,
208
- TextEncoder,
209
- TextDecoder,
210
- btoa,
211
- atob,
212
- ...globals,
213
- },
214
- { filename },
215
- );
216
- return module.exports;
217
- }
218
-
219
- /**
220
- * @param {string} filename
221
- * @param {ProbeBindings} [globals]
222
- * @returns {any}
223
- */
224
- function load(filename, globals) {
225
- return evaluate(fs.readFileSync(filename, "utf8"), filename, globals);
226
- }
227
-
228
- /**
229
- * @typedef {{
230
- * (url: string, options: object): Promise<unknown>;
231
- * raw: (url: string, options: object) => Promise<unknown>;
232
- * }} AuthFetch
233
- */
234
-
235
- /** @type {(filename: string, globals: ProbeBindings) => { useAuthFetch: () => { $authFetch: AuthFetch } }} */
236
- const loadAuthFetch = load;
237
-
238
- /** @param {boolean} raw */
239
- async function authRetry(raw) {
240
- /** @type {number[]} */
241
- const reads = [];
242
- /** @type {Array<{ unauthorized: true } | { token: string | null; retry: string | null }>} */
243
- const calls = [];
244
- let refreshes = 0;
245
- /**
246
- * @param {unknown} _request
247
- * @param {{ headers: Headers }} options
248
- */
249
- const baseFetch = async (_request, options) => {
250
- calls.push(
251
- calls.length
252
- ? {
253
- token: options.headers.get("authorization"),
254
- retry: options.headers.get("x-auth-retry"),
255
- }
256
- : { unauthorized: true },
257
- );
258
- if (calls.length === 1) throw { response: { status: 401 } };
259
- return calls.at(-1);
260
- };
261
- baseFetch.raw = baseFetch;
262
- const filename = path.join(
263
- layers,
264
- "dms-core/app/composables/auth/useAuthFetch.ts",
265
- );
266
- const { useAuthFetch } = loadAuthFetch(filename, {
267
- HTTP_UNAUTHORIZED: 401,
268
- useDmsUserSession: () => ({ loggedIn: { value: true } }),
269
- useSessionRecovery: () => ({
270
- refreshSession: async () => {
271
- refreshes++;
272
- return true;
273
- },
274
- reconcileSession: async () => {},
275
- redirectToAuth: async () => {},
276
- }),
277
- useDmsRuntimeConfig: () => ({ public: { dms: { baseURL: "/api" } } }),
278
- useDmsApp: () => ({ $i18n: { locale: { value: "en" } } }),
279
- /**
280
- * @param {unknown} _key
281
- * @param {() => unknown} initial
282
- */
283
- useDmsState: (_key, initial) => ({ value: initial() }),
284
- $fetch: { create: () => baseFetch },
285
- });
286
- const options = Object.defineProperty({}, "headers", {
287
- enumerable: true,
288
- get() {
289
- reads.push(reads.length + 1);
290
- return { authorization: `token${reads.length}` };
291
- },
292
- });
293
- const { $authFetch } = useAuthFetch();
294
- const result = await (raw ? $authFetch.raw : $authFetch)(
295
- "/resource",
296
- options,
297
- );
298
- return { result, reads, refreshes, calls };
299
- }
300
-
301
- /** @type {(filename: string) => { writeAt: (tree: object, path: string[], value: unknown) => void; readAt: (tree: object, path: string[]) => unknown }} */
302
- const loadPreferences = load;
303
-
304
- function preferences() {
305
- const filename = path.join(
306
- layers,
307
- "dms-core/app/build/composables/user/preferencesCookie.ts",
308
- );
309
- const { writeAt, readAt } = loadPreferences(filename);
310
- /** @type {string[]} */
311
- const events = [];
312
- /** @type {{ leaf?: string }} */
313
- const first = {};
314
- /** @type {{ leaf?: string }} */
315
- const second = {};
316
- let reads = 0;
317
- const tree = Object.defineProperty({}, "branch", {
318
- enumerable: true,
319
- get() {
320
- events.push(`get:${++reads}`);
321
- return reads === 1 ? first : second;
322
- },
323
- });
324
- writeAt(tree, ["branch", "leaf"], "written");
325
- const plain = {};
326
- writeAt(plain, ["a", "b"], 7);
327
- /** @type {string[]} */
328
- const creationEvents = [];
329
- /** @type {{ leaf?: string }} */
330
- const afterAssignment = {};
331
- /** @type {{ leaf?: string }} */
332
- let assigned;
333
- let creationReads = 0;
334
- const creatingTree = Object.defineProperty({}, "branch", {
335
- get() {
336
- creationEvents.push(`get:${++creationReads}`);
337
- return creationReads === 1 ? undefined : afterAssignment;
338
- },
339
- /** @param {{ leaf?: string }} value */
340
- set(value) {
341
- creationEvents.push("set");
342
- assigned = value;
343
- },
344
- });
345
- writeAt(creatingTree, ["branch", "leaf"], "created");
346
- return {
347
- events,
348
- first: first.leaf ?? null,
349
- second: second.leaf ?? null,
350
- plain: readAt(plain, ["a", "b"]),
351
- creation: {
352
- events: creationEvents,
353
- assigned: assigned.leaf ?? null,
354
- reread: afterAssignment.leaf ?? null,
355
- },
356
- };
357
- }
358
-
359
- /**
360
- * @typedef {{
361
- * setup: (
362
- * props: object,
363
- * context: { expose: () => void },
364
- * ) => {
365
- * HANDOFF_ACTIONS: object;
366
- * runHandoffAction: (handoff: object) => unknown;
367
- * };
368
- * }} OauthComponent
369
- */
370
-
371
- /** @type {(source: string, filename: string, globals: ProbeBindings, imports: ProbeBindings) => { default: OauthComponent }} */
372
- const evaluateOauth = evaluate;
373
-
374
- function oauth() {
375
- const filename = path.join(
376
- layers,
377
- "dms-auth/app/custom-pages/auth/oauth-complete.vue",
378
- );
379
- const { descriptor } = sfc.parse(fs.readFileSync(filename, "utf8"), {
380
- filename,
381
- });
382
- const compiled = sfc.compileScript(descriptor, { id: "oauth-probe" });
383
- const { default: component } = evaluateOauth(
384
- compiled.content,
385
- filename,
386
- {
387
- useDmsRoute: () => ({ query: {} }),
388
- useHomepage: () => "/home",
389
- useDmsApp: () => ({}),
390
- /** @param {() => unknown} get */
391
- computed: (get) => ({
392
- get value() {
393
- return get();
394
- },
395
- }),
396
- onMounted: () => {},
397
- },
398
- {
399
- vue: {
400
- /** @param {object} options */
401
- defineComponent: (options) => options,
402
- },
403
- },
404
- );
405
- const exposed = component.setup({}, { expose() {} });
406
- /** @type {string[]} */
407
- const events = [];
408
- const actions = exposed.HANDOFF_ACTIONS;
409
- Object.defineProperty(actions, "none", {
410
- get() {
411
- events.push("action:get");
412
- /**
413
- * @this {unknown}
414
- * @param {{ token: string }} handoff
415
- */
416
- return function (handoff) {
417
- events.push(
418
- this === actions ? "receiver:actions" : "receiver:undefined",
419
- );
420
- return handoff.token;
421
- };
422
- },
423
- });
424
- const handoff = {
425
- get kind() {
426
- events.push("kind:get");
427
- return "none";
428
- },
429
- token: "handoff-token",
430
- };
431
- const result = exposed.runHandoffAction(handoff);
432
- return { result, events };
433
- }
434
-
435
- /**
436
- * @param {unknown} value
437
- * @returns {value is (...args: never[]) => unknown}
438
- */
439
- function isCallable(value) {
440
- return typeof value === "function";
441
- }
442
-
443
- /**
444
- * @param {unknown} value
445
- * @returns {value is Record<string, unknown>}
446
- */
447
- function isObjectLike(value) {
448
- return typeof value === "object" && value !== null;
449
- }
450
-
451
- /**
452
- * @param {unknown} value
453
- * @returns {value is unknown[]}
454
- */
455
- function isList(value) {
456
- return Array.isArray(value);
457
- }
458
-
459
- /**
460
- * @param {unknown} error
461
- * @returns {error is { message: string }}
462
- */
463
- function hasMessage(error) {
464
- return (
465
- isObjectLike(error) &&
466
- "message" in error &&
467
- typeof error.message === "string"
468
- );
469
- }
470
-
471
- /** @param {string} expression */
472
- function runtimeDeclaration(expression) {
473
- try {
474
- const javascript = ts.transpileModule(`module.exports = (${expression});`, {
475
- compilerOptions,
476
- }).outputText;
477
- const module = { exports: {} };
478
- const vue = req("vue");
479
- vm.runInNewContext(javascript, {
480
- module,
481
- _mergeDefaults: vue.mergeDefaults,
482
- _mergeModels: vue.mergeModels,
483
- });
484
- /**
485
- * @param {unknown} value
486
- * @returns {unknown}
487
- */
488
- const serialize = (value) => {
489
- if (value === undefined) return { undefined: true };
490
- if (isCallable(value))
491
- return {
492
- function: value.name || null,
493
- code: value.toString().replace(/\s+/g, " "),
494
- };
495
- if (isList(value)) return Array.from(value, serialize);
496
- if (isObjectLike(value))
497
- return Object.fromEntries(
498
- Object.entries(value).map(([key, entry]) => [key, serialize(entry)]),
499
- );
500
- return value;
501
- };
502
- return { status: "evaluated", value: serialize(module.exports) };
503
- } catch (error) {
504
- const reason = hasMessage(error) ? error.message : undefined;
505
- return { status: "runtime-unresolved", reason };
506
- }
507
- }
508
-
509
- /** @typedef {{ compiled: string; runtime: ReturnType<typeof runtimeDeclaration> }} DeclarationContract */
510
-
511
- function contracts() {
512
- const manifest = Object.entries(componentManifest).flatMap(
513
- ([prefix, files]) => files.map((file) => `${prefix}${file}`),
514
- );
515
- const printer = ts.createPrinter({ removeComments: true });
516
- /** @param {string} source */
517
- const normalize = (source) =>
518
- printer
519
- .printFile(
520
- ts.createSourceFile(
521
- "contract.ts",
522
- source,
523
- ts.ScriptTarget.Latest,
524
- true,
525
- ),
526
- )
527
- .trim();
528
- return manifest.map((relative) => {
529
- const filename = path.join(layers, relative);
530
- const { descriptor } = sfc.parse(fs.readFileSync(filename, "utf8"), {
531
- filename,
532
- });
533
- try {
534
- const compiled = sfc.compileScript(descriptor, {
535
- id: "contract",
536
- fs: {
537
- fileExists: (file) =>
538
- fs.existsSync(file) && fs.statSync(file).isFile(),
539
- readFile: (file) => fs.readFileSync(file, "utf8"),
540
- },
541
- });
542
- const ast = ts.createSourceFile(
543
- "compiled.ts",
544
- compiled.content,
545
- ts.ScriptTarget.Latest,
546
- true,
547
- );
548
- /** @type {{ path: string; status: string; props: DeclarationContract | null; emits: DeclarationContract | null; macros: string[]; [key: string]: unknown }} */
549
- const result = {
550
- path: relative,
551
- status: "compiled",
552
- props: null,
553
- emits: null,
554
- macros: [],
555
- };
556
- /** @param {import("typescript").Node} node */
557
- const inspect = (node) => {
558
- if (
559
- ts.isPropertyAssignment(node) &&
560
- ["props", "emits"].includes(node.name.getText(ast))
561
- ) {
562
- const expression = node.initializer.getText(ast);
563
- result[node.name.getText(ast)] = {
564
- compiled: normalize(expression),
565
- runtime: runtimeDeclaration(expression),
566
- };
567
- }
568
- ts.forEachChild(node, inspect);
569
- };
570
- inspect(ast);
571
- const raw = ts.createSourceFile(
572
- "source.ts",
573
- descriptor.scriptSetup?.content ?? "",
574
- ts.ScriptTarget.Latest,
575
- true,
576
- );
577
- /** @param {import("typescript").Node} node */
578
- const macro = (node) => {
579
- if (
580
- ts.isCallExpression(node) &&
581
- ["defineExpose", "defineSlots", "defineOptions"].includes(
582
- node.expression.getText(raw),
583
- )
584
- ) {
585
- result.macros.push(normalize(node.getText(raw)));
586
- }
587
- ts.forEachChild(node, macro);
588
- };
589
- macro(raw);
590
- return result;
591
- } catch (error) {
592
- if (!hasMessage(error)) throw error;
593
- return {
594
- path: relative,
595
- status: "compiler-unresolved",
596
- reason: error.message
597
- .split("\n")
598
- .find((line) => line.trim())
599
- .replaceAll(root, "<checkout>"),
600
- };
601
- }
602
- });
603
- }
604
-
605
- module.exports = {
606
- frontend,
607
- layers,
608
- req,
609
- ts,
610
- evaluate,
611
- load,
612
- isObjectLike,
613
- observe: async () => ({
614
- authRetry: await authRetry(false),
615
- authRawRetry: await authRetry(true),
616
- preferences: preferences(),
617
- oauth: oauth(),
618
- componentContracts: contracts(),
619
- }),
620
- };