@shwfed/config 2.0.1 → 2.0.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.
Files changed (19) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/actions/config.vue +1 -1
  3. package/dist/runtime/components/form/config.vue +1 -1
  4. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.date/schema.d.ts +1 -1
  5. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.date/schema.js +2 -2
  6. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.icon/schema.d.ts +1 -1
  7. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.icon/schema.js +2 -2
  8. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.number/schema.d.ts +1 -1
  9. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.number/schema.js +2 -2
  10. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/schema.d.ts +1 -1
  11. package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/schema.js +2 -2
  12. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch/schema.d.ts +1 -1
  13. package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch/schema.js +2 -2
  14. package/dist/runtime/components/table/config.vue +1 -1
  15. package/dist/runtime/components/table/index.vue +5 -1
  16. package/dist/runtime/components/table/utils/resolve.d.ts +1 -1
  17. package/dist/runtime/vendor/cel-js/lib/registry.d.ts +4 -1
  18. package/dist/runtime/vendor/cel-js/lib/registry.js +8 -2
  19. package/package.json +1 -1
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shwfed",
3
3
  "configKey": "shwfed",
4
- "version": "2.0.1",
4
+ "version": "2.0.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -60,7 +60,7 @@ const advertisedContext = (() => {
60
60
  if (baseline.has(v.name)) continue;
61
61
  out[v.name] = {
62
62
  type: v.type,
63
- label: v.name,
63
+ label: v.label ?? v.name,
64
64
  description: v.description ?? void 0,
65
65
  value: void 0
66
66
  };
@@ -47,7 +47,7 @@ const advertisedContext = (() => {
47
47
  if (baseline.has(v.name)) continue;
48
48
  out[v.name] = {
49
49
  type: v.type,
50
- label: v.name,
50
+ label: v.label ?? v.name,
51
51
  description: v.description ?? void 0,
52
52
  value: void 0
53
53
  };
@@ -37,4 +37,4 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
37
37
  compatibilityDate: Schema.Literal<["2026-04-14"]>;
38
38
  }>;
39
39
  export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
40
- export declare function toColumnDef(value: Value, { getLocaleText, $cel, inheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
40
+ export declare function toColumnDef(value: Value, { getLocaleText, $cel, getInheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
@@ -21,12 +21,12 @@ export function schema(configure) {
21
21
  })
22
22
  }).annotations({ title: "DateRenderer", description: "\u65E5\u671F\u6E32\u67D3\u5668" });
23
23
  }
24
- export function toColumnDef(value, { getLocaleText, $cel, inheritedContext }) {
24
+ export function toColumnDef(value, { getLocaleText, $cel, getInheritedContext }) {
25
25
  return {
26
26
  header: getLocaleText(value.title),
27
27
  accessorFn: (row, index) => {
28
28
  try {
29
- return Effect.runSync($cel(value.accessor, { ...inheritedContext, row, index }));
29
+ return Effect.runSync($cel(value.accessor, { ...getInheritedContext(), row, index }));
30
30
  } catch (e) {
31
31
  console.error("[shwfed-table] accessor failed", e);
32
32
  return void 0;
@@ -37,4 +37,4 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
37
37
  compatibilityDate: Schema.Literal<["2026-04-14"]>;
38
38
  }>;
39
39
  export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
40
- export declare function toColumnDef(value: Value, { getLocaleText, $cel, inheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
40
+ export declare function toColumnDef(value: Value, { getLocaleText, $cel, getInheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
@@ -24,12 +24,12 @@ export function schema(configure) {
24
24
  align: Schema.optionalWith(Align.annotations({ title: "\u5BF9\u9F50" }), { default: () => "center" })
25
25
  }).annotations({ title: "IconRenderer", description: "\u56FE\u6807\u6E32\u67D3\u5668" });
26
26
  }
27
- export function toColumnDef(value, { getLocaleText, $cel, inheritedContext }) {
27
+ export function toColumnDef(value, { getLocaleText, $cel, getInheritedContext }) {
28
28
  return {
29
29
  header: getLocaleText(value.title),
30
30
  accessorFn: (row, index) => {
31
31
  try {
32
- return Effect.runSync($cel(value.accessor, { ...inheritedContext, row, index }));
32
+ return Effect.runSync($cel(value.accessor, { ...getInheritedContext(), row, index }));
33
33
  } catch (e) {
34
34
  console.error("[shwfed-table] accessor failed", e);
35
35
  return void 0;
@@ -41,4 +41,4 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
41
41
  compatibilityDate: Schema.Literal<["2026-04-14"]>;
42
42
  }>;
43
43
  export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
44
- export declare function toColumnDef(value: Value, { getLocaleText, $cel, inheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
44
+ export declare function toColumnDef(value: Value, { getLocaleText, $cel, getInheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
@@ -29,12 +29,12 @@ export function schema(configure) {
29
29
  }))
30
30
  }).annotations({ title: "NumberRenderer", description: "\u6570\u503C\u6E32\u67D3\u5668" });
31
31
  }
32
- export function toColumnDef(value, { getLocaleText, $cel, inheritedContext }) {
32
+ export function toColumnDef(value, { getLocaleText, $cel, getInheritedContext }) {
33
33
  return {
34
34
  header: getLocaleText(value.title),
35
35
  accessorFn: (row, index) => {
36
36
  try {
37
- return Effect.runSync($cel(value.accessor, { ...inheritedContext, row, index }));
37
+ return Effect.runSync($cel(value.accessor, { ...getInheritedContext(), row, index }));
38
38
  } catch (e) {
39
39
  console.error("[shwfed-table] accessor failed", e);
40
40
  return void 0;
@@ -40,4 +40,4 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
40
40
  compatibilityDate: Schema.Literal<["2026-04-14"]>;
41
41
  }>;
42
42
  export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
43
- export declare function toColumnDef(value: Value, { getLocaleText, $cel, inheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
43
+ export declare function toColumnDef(value: Value, { getLocaleText, $cel, getInheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
@@ -26,12 +26,12 @@ export function schema(configure) {
26
26
  }))
27
27
  }).annotations({ title: "TextRenderer", description: "\u6587\u672C\u6E32\u67D3\u5668" });
28
28
  }
29
- export function toColumnDef(value, { getLocaleText, $cel, inheritedContext }) {
29
+ export function toColumnDef(value, { getLocaleText, $cel, getInheritedContext }) {
30
30
  return {
31
31
  header: getLocaleText(value.title),
32
32
  accessorFn: (row, index) => {
33
33
  try {
34
- return Effect.runSync($cel(value.accessor, { ...inheritedContext, row, index }));
34
+ return Effect.runSync($cel(value.accessor, { ...getInheritedContext(), row, index }));
35
35
  } catch (e) {
36
36
  console.error("[shwfed-table] accessor failed", e);
37
37
  return void 0;
@@ -39,4 +39,4 @@ export declare function schema(configure: (env: Environment) => void): Schema.St
39
39
  compatibilityDate: Schema.Literal<["2026-05-13"]>;
40
40
  }>;
41
41
  export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
42
- export declare function toColumnDef(value: Value, { getLocaleText, $cel, inheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
42
+ export declare function toColumnDef(value: Value, { getLocaleText, $cel, getInheritedContext }: ColumnDefDeps): Partial<ColumnDef<unknown, unknown>>;
@@ -43,12 +43,12 @@ export function schema(configure) {
43
43
  }))
44
44
  }).annotations({ title: "SwitchRenderer", description: "\u5F00\u5173\u6E32\u67D3\u5668\uFF08\u53EF\u7F16\u8F91\uFF09" });
45
45
  }
46
- export function toColumnDef(value, { getLocaleText, $cel, inheritedContext }) {
46
+ export function toColumnDef(value, { getLocaleText, $cel, getInheritedContext }) {
47
47
  return {
48
48
  header: getLocaleText(value.title),
49
49
  accessorFn: (row, index) => {
50
50
  try {
51
- return Effect.runSync($cel(value.accessor, { ...inheritedContext, row, index }));
51
+ return Effect.runSync($cel(value.accessor, { ...getInheritedContext(), row, index }));
52
52
  } catch (e) {
53
53
  console.error("[shwfed-table] switch accessor failed", e);
54
54
  return void 0;
@@ -155,7 +155,7 @@ const advertisedHostContext = (() => {
155
155
  if (baseline.has(v.name)) continue;
156
156
  out[v.name] = {
157
157
  type: v.type,
158
- label: v.name,
158
+ label: v.label ?? v.name,
159
159
  description: v.description ?? void 0,
160
160
  value: void 0
161
161
  };
@@ -79,7 +79,11 @@ function translateColumn(column) {
79
79
  if (!entry) {
80
80
  throw new Error(`[shwfed-table] no column registered for ${column.type}@${column.compatibilityDate}`);
81
81
  }
82
- const contribution = entry.toColumnDef(column, { getLocaleText, $cel, inheritedContext: celBindings(inheritedContext) });
82
+ const contribution = entry.toColumnDef(column, {
83
+ getLocaleText,
84
+ $cel,
85
+ getInheritedContext: () => celBindings(inheritedContext)
86
+ });
83
87
  return {
84
88
  ...contribution,
85
89
  id: column.id,
@@ -13,7 +13,7 @@ export type ColumnMetadata = Readonly<{
13
13
  export type ColumnDefDeps = Readonly<{
14
14
  getLocaleText: (value: LocaleValue | undefined) => string | undefined;
15
15
  $cel: CelEvaluator;
16
- inheritedContext: Record<string, unknown>;
16
+ getInheritedContext: () => Record<string, unknown>;
17
17
  }>;
18
18
  type ToColumnDef = (value: any, deps: ColumnDefDeps) => Partial<ColumnDef<unknown, unknown>>;
19
19
  export type ColumnEntry = Readonly<{
@@ -40,9 +40,10 @@ export declare class VariableDeclaration {
40
40
  name: string;
41
41
  type: TypeDeclaration;
42
42
  description: string | null;
43
+ label: string | null;
43
44
  constant: boolean;
44
45
  value: unknown;
45
- constructor(name: string, type: TypeDeclaration, description?: string | null, value?: unknown);
46
+ constructor(name: string, type: TypeDeclaration, description?: string | null, value?: unknown, label?: string | null);
46
47
  }
47
48
  export declare class FunctionDeclaration {
48
49
  name: string;
@@ -128,6 +129,7 @@ export declare class Registry {
128
129
  functionCandidates(rec: boolean, name: string, argLen: number): Candidates;
129
130
  registerVariable(name: string | Record<string, unknown>, type?: string | TypeDeclaration | Record<string, unknown>, opts?: {
130
131
  description?: string;
132
+ label?: string;
131
133
  value?: unknown;
132
134
  }): this;
133
135
  registerConstant(name: string | Record<string, unknown>, type?: string, value?: unknown): this;
@@ -155,6 +157,7 @@ export declare class Registry {
155
157
  variables: {
156
158
  name: string;
157
159
  description: string | null;
160
+ label: string | null;
158
161
  type: string;
159
162
  }[];
160
163
  functions: {
@@ -295,12 +295,14 @@ export class VariableDeclaration {
295
295
  name;
296
296
  type;
297
297
  description;
298
+ label;
298
299
  constant;
299
300
  value;
300
- constructor(name, type, description, value) {
301
+ constructor(name, type, description, value, label) {
301
302
  this.name = name;
302
303
  this.type = type;
303
304
  this.description = description ?? null;
305
+ this.label = label ?? null;
304
306
  this.constant = value !== void 0;
305
307
  this.value = value;
306
308
  objFreeze(this);
@@ -738,9 +740,11 @@ export class Registry {
738
740
  registerVariable(name, type, opts) {
739
741
  if (this.#locked) throw new Error("Cannot modify frozen registry");
740
742
  let description = opts?.description;
743
+ let label = opts?.label;
741
744
  let value;
742
745
  if (typeof name === "string" && typeof type === "object" && !(type instanceof TypeDeclaration)) {
743
746
  description = type.description;
747
+ label = type.label;
744
748
  value = type.value;
745
749
  if (type.schema) type = this.registerType({ name: `$${name}`, schema: type.schema }).type;
746
750
  else type = type.type;
@@ -748,6 +752,7 @@ export class Registry {
748
752
  if (name.schema) type = this.registerType({ name: `$${name.name}`, schema: name.schema }).type;
749
753
  else type = name.type;
750
754
  description = name.description;
755
+ label = name.label;
751
756
  value = name.value;
752
757
  name = name.name;
753
758
  }
@@ -757,7 +762,7 @@ export class Registry {
757
762
  if (typeof type === "string") type = this.getType(type);
758
763
  else if (!(type instanceof TypeDeclaration)) throw invalidVar(`type is required`);
759
764
  this.#ensureOwnVariables();
760
- this.variables.set(name, new VariableDeclaration(name, type, description, value));
765
+ this.variables.set(name, new VariableDeclaration(name, type, description, value, label));
761
766
  return this;
762
767
  }
763
768
  #registerSchemaAsType(name, schema) {
@@ -985,6 +990,7 @@ export class Registry {
985
990
  variables.push({
986
991
  name: varDecl.name,
987
992
  description: varDecl.description || null,
993
+ label: varDecl.label || null,
988
994
  type: varDecl.type.name
989
995
  });
990
996
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/config",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Configurable UI for SHWFED",
5
5
  "type": "module",
6
6
  "publishConfig": {