@vortexm/vjt 0.1.10 → 0.1.12

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/dist/index.js CHANGED
@@ -3900,7 +3900,7 @@ var NetworkRuntime = class {
3900
3900
  }
3901
3901
  }
3902
3902
  async executeRequest(requestName, currentValue) {
3903
- const definition = this.requestsMap[requestName];
3903
+ const definition = resolveRequestDefinition(this.requestsMap, requestName);
3904
3904
  if (!definition) {
3905
3905
  return null;
3906
3906
  }
@@ -4125,6 +4125,24 @@ var NetworkRuntime = class {
4125
4125
  await this.rerenderRoot();
4126
4126
  }
4127
4127
  };
4128
+ function isRequestDefinitionLike(value) {
4129
+ return typeof value === "object" && value !== null && "request" in value && "name" in value;
4130
+ }
4131
+ function resolveRequestDefinition(requestsMap, requestName) {
4132
+ const directMatch = requestsMap[requestName];
4133
+ if (isRequestDefinitionLike(directMatch)) {
4134
+ return directMatch;
4135
+ }
4136
+ const segments = requestName.split(".").filter(Boolean);
4137
+ let current = requestsMap;
4138
+ for (const segment of segments) {
4139
+ if (typeof current !== "object" || current === null || !(segment in current)) {
4140
+ return void 0;
4141
+ }
4142
+ current = current[segment];
4143
+ }
4144
+ return isRequestDefinitionLike(current) ? current : void 0;
4145
+ }
4128
4146
 
4129
4147
  // src/lib/references.ts
4130
4148
  function isPlainObject2(value) {
@@ -4256,13 +4274,16 @@ var ReferenceRuntime = class {
4256
4274
  constructor(host) {
4257
4275
  this.host = host;
4258
4276
  }
4259
- isEmptyReference(reference, currentValue, responseValue) {
4260
- return isReferenceValueEmpty(this.resolveReference(reference, currentValue, responseValue));
4277
+ isEmptyReference(reference, currentValue, responseValue, inputValue) {
4278
+ return isReferenceValueEmpty(this.resolveReference(reference, currentValue, responseValue, inputValue));
4261
4279
  }
4262
- resolveReference(reference, currentValue, responseValue) {
4280
+ resolveReference(reference, currentValue, responseValue, inputValue = currentValue) {
4263
4281
  if (reference === "current") {
4264
4282
  return currentValue;
4265
4283
  }
4284
+ if (reference === "input") {
4285
+ return inputValue;
4286
+ }
4266
4287
  if (reference === "message") {
4267
4288
  return responseValue;
4268
4289
  }
@@ -4275,6 +4296,9 @@ var ReferenceRuntime = class {
4275
4296
  if (reference.startsWith("current.")) {
4276
4297
  return this.resolveCurrentReference(reference.slice(8), currentValue);
4277
4298
  }
4299
+ if (reference.startsWith("input.")) {
4300
+ return readPath(inputValue, reference.slice(6).split("."));
4301
+ }
4278
4302
  if (reference.startsWith("cookies.")) {
4279
4303
  return getCookieValue(reference.slice(8));
4280
4304
  }
@@ -4513,20 +4537,20 @@ var ReferenceRuntime = class {
4513
4537
  }
4514
4538
  }
4515
4539
  }
4516
- resolveMappedValue(template, currentValue, responseValue) {
4540
+ resolveMappedValue(template, currentValue, responseValue, inputValue = currentValue) {
4517
4541
  if (typeof template === "string") {
4518
4542
  if (template.startsWith("$ref:")) {
4519
- return this.resolveReference(template.slice(5), currentValue, responseValue);
4543
+ return this.resolveReference(template.slice(5), currentValue, responseValue, inputValue);
4520
4544
  }
4521
4545
  if (template.includes("$ref:")) {
4522
4546
  return template.replaceAll(/\$ref:([A-Za-z0-9_.]+)/g, (_match, ref) => {
4523
- const resolved = this.resolveReference(ref, currentValue, responseValue);
4547
+ const resolved = this.resolveReference(ref, currentValue, responseValue, inputValue);
4524
4548
  return stringifyReferenceValue(resolved);
4525
4549
  });
4526
4550
  }
4527
4551
  }
4528
4552
  if (Array.isArray(template)) {
4529
- return template.map((entry) => this.resolveMappedValue(entry, currentValue, responseValue));
4553
+ return template.map((entry) => this.resolveMappedValue(entry, currentValue, responseValue, inputValue));
4530
4554
  }
4531
4555
  if (isPlainObject2(template)) {
4532
4556
  const result = {};
@@ -4537,7 +4561,7 @@ var ReferenceRuntime = class {
4537
4561
  if (isTrustedConfigOnlyKey(key) && templateValueUsesReference(value)) {
4538
4562
  continue;
4539
4563
  }
4540
- result[key] = this.resolveMappedValue(value, currentValue, responseValue);
4564
+ result[key] = this.resolveMappedValue(value, currentValue, responseValue, inputValue);
4541
4565
  }
4542
4566
  return result;
4543
4567
  }
@@ -4794,8 +4818,9 @@ var ActionRuntime = class {
4794
4818
  responseValue: context.responseValue,
4795
4819
  pointer: context.pointer ?? null
4796
4820
  });
4797
- if (this.actionsMap[name]) {
4798
- return this.runActions(this.actionsMap[name], inputValue, context);
4821
+ const customAction = resolveActionDefinition(this.actionsMap, name);
4822
+ if (customAction) {
4823
+ return this.runActions(customAction, inputValue, context);
4799
4824
  }
4800
4825
  if (name.startsWith("refresh ")) {
4801
4826
  await this.refreshWidgetTree(name.slice(8));
@@ -4822,7 +4847,7 @@ var ActionRuntime = class {
4822
4847
  return null;
4823
4848
  }
4824
4849
  if (name.startsWith("play ")) {
4825
- await this.playAudio(this.resolveReference(name.slice(5), context.currentValue, context.responseValue));
4850
+ await this.playAudio(this.resolveReference(name.slice(5), context.currentValue, context.responseValue, inputValue));
4826
4851
  return null;
4827
4852
  }
4828
4853
  if (name === "copyToClipboard") {
@@ -4935,12 +4960,18 @@ var ActionRuntime = class {
4935
4960
  if (name.startsWith("get ")) {
4936
4961
  const reference = name.slice(4);
4937
4962
  if (Array.isArray(inputValue) && this.isCurrentScopedReference(reference)) {
4938
- return inputValue.map((entry) => this.resolveReference(reference, entry, context.responseValue)).filter((entry) => entry !== null && entry !== void 0);
4963
+ return inputValue.map((entry) => this.resolveReference(reference, entry, context.responseValue, entry)).filter((entry) => entry !== null && entry !== void 0);
4939
4964
  }
4940
- return this.resolveReference(reference, context.currentValue, context.responseValue);
4965
+ return this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
4966
+ }
4967
+ if (name.startsWith("getFirst ")) {
4968
+ return this.getCollectionBoundaryByReference(name.slice(9), inputValue, context, "first");
4969
+ }
4970
+ if (name.startsWith("getLast ")) {
4971
+ return this.getCollectionBoundaryByReference(name.slice(8), inputValue, context, "last");
4941
4972
  }
4942
4973
  if (name.startsWith("count ")) {
4943
- return this.countValue(this.resolveReference(name.slice(6), context.currentValue, context.responseValue));
4974
+ return this.countValue(this.resolveReference(name.slice(6), context.currentValue, context.responseValue, inputValue));
4944
4975
  }
4945
4976
  if (name === "indexOf") {
4946
4977
  if (isListElementLike(context.currentValue)) {
@@ -4972,35 +5003,47 @@ var ActionRuntime = class {
4972
5003
  if (name === "dec") {
4973
5004
  return this.toNumber(inputValue) - 1;
4974
5005
  }
5006
+ if (name === "trim") {
5007
+ return this.stringifyValue(inputValue).trim();
5008
+ }
5009
+ if (name === "dedupLineBreaks") {
5010
+ return this.stringifyValue(inputValue).replaceAll(/\r\n/g, "\n").replaceAll(/\n{3,}/g, "\n\n");
5011
+ }
4975
5012
  if (name.startsWith("equals ")) {
4976
- return this.resolveReference(name.slice(7), context.currentValue, context.responseValue) === action.args;
5013
+ return this.resolveReference(name.slice(7), context.currentValue, context.responseValue, inputValue) === action.args;
4977
5014
  }
4978
5015
  if (name.startsWith("greaterThan ")) {
4979
- return this.toNumber(inputValue) > this.toNumber(this.resolveReference(name.slice(12), context.currentValue, context.responseValue));
5016
+ return this.toNumber(inputValue) > this.toNumber(this.resolveReference(name.slice(12), context.currentValue, context.responseValue, inputValue));
4980
5017
  }
4981
5018
  if (name.startsWith("greaterThanOrEquals ")) {
4982
- return this.toNumber(inputValue) >= this.toNumber(this.resolveReference(name.slice(20), context.currentValue, context.responseValue));
5019
+ return this.toNumber(inputValue) >= this.toNumber(this.resolveReference(name.slice(20), context.currentValue, context.responseValue, inputValue));
4983
5020
  }
4984
5021
  if (name.startsWith("lessThan ")) {
4985
- return this.toNumber(inputValue) < this.toNumber(this.resolveReference(name.slice(9), context.currentValue, context.responseValue));
5022
+ return this.toNumber(inputValue) < this.toNumber(this.resolveReference(name.slice(9), context.currentValue, context.responseValue, inputValue));
4986
5023
  }
4987
5024
  if (name.startsWith("lessThanOrEquals ")) {
4988
- return this.toNumber(inputValue) <= this.toNumber(this.resolveReference(name.slice(17), context.currentValue, context.responseValue));
5025
+ return this.toNumber(inputValue) <= this.toNumber(this.resolveReference(name.slice(17), context.currentValue, context.responseValue, inputValue));
4989
5026
  }
4990
5027
  if (name.startsWith("and ")) {
4991
- return Boolean(inputValue) && Boolean(this.resolveReference(name.slice(4), context.currentValue, context.responseValue));
5028
+ return Boolean(inputValue) && Boolean(this.resolveReference(name.slice(4), context.currentValue, context.responseValue, inputValue));
4992
5029
  }
4993
5030
  if (name.startsWith("isEmpty ")) {
4994
- return this.isEmptyReference(name.slice(8), context.currentValue, context.responseValue);
5031
+ return this.isEmptyReference(name.slice(8), context.currentValue, context.responseValue, inputValue);
4995
5032
  }
4996
5033
  if (name.startsWith("set ")) {
4997
5034
  const args = typeof action.args === "object" && action.args !== null && !Array.isArray(action.args) ? action.args : void 0;
4998
5035
  this.assignReference(name.slice(4), inputValue, context.currentValue, args);
4999
5036
  return inputValue;
5000
5037
  }
5038
+ if (name.startsWith("setFirst ")) {
5039
+ return this.setCollectionBoundaryByReference(name.slice(9), inputValue, context, "first");
5040
+ }
5041
+ if (name.startsWith("setLast ")) {
5042
+ return this.setCollectionBoundaryByReference(name.slice(8), inputValue, context, "last");
5043
+ }
5001
5044
  if (name.startsWith("append ")) {
5002
5045
  const reference = name.slice(7);
5003
- const currentText = this.resolveReference(reference, context.currentValue, context.responseValue);
5046
+ const currentText = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5004
5047
  const nextValue = `${this.stringifyValue(currentText)}${this.stringifyValue(action.args)}`;
5005
5048
  this.assignReference(reference, nextValue, context.currentValue);
5006
5049
  return nextValue;
@@ -5008,9 +5051,9 @@ var ActionRuntime = class {
5008
5051
  if (name.startsWith("filter ")) {
5009
5052
  const reference = name.slice(7);
5010
5053
  if (Array.isArray(inputValue) && this.isCurrentScopedReference(reference)) {
5011
- return inputValue.filter((entry) => this.resolveReference(reference, entry, context.responseValue));
5054
+ return inputValue.filter((entry) => this.resolveReference(reference, entry, context.responseValue, entry));
5012
5055
  }
5013
- const value = this.resolveReference(reference, context.currentValue, context.responseValue);
5056
+ const value = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5014
5057
  return value ? inputValue : null;
5015
5058
  }
5016
5059
  if (name === "remove") {
@@ -5026,7 +5069,7 @@ var ActionRuntime = class {
5026
5069
  return null;
5027
5070
  }
5028
5071
  if (name.startsWith("add ")) {
5029
- const valueToAdd = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(4), context.currentValue, context.responseValue)));
5072
+ const valueToAdd = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(4), context.currentValue, context.responseValue, inputValue)));
5030
5073
  const listState = this.getCurrentListState(context.currentValue);
5031
5074
  if (listState && Array.isArray(listState.elements)) {
5032
5075
  listState.elements.push(valueToAdd);
@@ -5053,7 +5096,7 @@ var ActionRuntime = class {
5053
5096
  return inputValue;
5054
5097
  }
5055
5098
  if (name.startsWith("insert ")) {
5056
- const valueToInsert = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(7), context.currentValue, context.responseValue)));
5099
+ const valueToInsert = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(7), context.currentValue, context.responseValue, inputValue)));
5057
5100
  const listState = this.getCurrentListState(context.currentValue);
5058
5101
  if (listState && Array.isArray(listState.elements) && typeof context.currentValue === "object" && context.currentValue !== null && "index" in context.currentValue) {
5059
5102
  const index = context.currentValue.index;
@@ -5084,9 +5127,12 @@ var ActionRuntime = class {
5084
5127
  }
5085
5128
  if (name === "map") {
5086
5129
  if (Array.isArray(inputValue)) {
5087
- return inputValue.map((entry) => this.resolveMappedValue(action.args, entry, context.responseValue));
5130
+ return inputValue.map((entry) => this.resolveMappedValue(action.args, entry, context.responseValue, entry));
5088
5131
  }
5089
- return this.resolveMappedValue(action.args, inputValue, context.responseValue);
5132
+ return this.resolveMappedValue(action.args, inputValue, context.responseValue, inputValue);
5133
+ }
5134
+ if (name === "setInput") {
5135
+ return this.resolveMappedValue(action.args, context.currentValue, context.responseValue, inputValue);
5090
5136
  }
5091
5137
  if (name === "ifelse") {
5092
5138
  const branches = isIfElseArgs(action.args) ? action.args : null;
@@ -5128,6 +5174,63 @@ var ActionRuntime = class {
5128
5174
  }
5129
5175
  return JSON.stringify(value);
5130
5176
  }
5177
+ getCollectionBoundaryByReference(reference, inputValue, context, boundary) {
5178
+ const collection = this.resolveCollectionReference(reference, inputValue, context);
5179
+ if (!collection || collection.length === 0) {
5180
+ return null;
5181
+ }
5182
+ return collection[boundary === "first" ? 0 : collection.length - 1];
5183
+ }
5184
+ setCollectionBoundaryByReference(reference, inputValue, context, boundary) {
5185
+ const state = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5186
+ const directCollection = this.getWidgetCollection(this.asWidgetState(state));
5187
+ if (directCollection && directCollection.length > 0) {
5188
+ directCollection[boundary === "first" ? 0 : directCollection.length - 1] = this.cloneValue(this.unwrapListValue(inputValue));
5189
+ const widgetState = this.asWidgetState(state);
5190
+ if (widgetState && (widgetState.widget === "list" || widgetState.widget === "grid-view")) {
5191
+ this.clearListElementState(widgetState.key);
5192
+ }
5193
+ return inputValue;
5194
+ }
5195
+ const collection = this.resolveCollectionReference(reference, inputValue, context);
5196
+ if (!collection || collection.length === 0) {
5197
+ return inputValue;
5198
+ }
5199
+ const nextCollection = collection.map((entry) => this.cloneValue(this.unwrapListValue(entry)));
5200
+ nextCollection[boundary === "first" ? 0 : nextCollection.length - 1] = this.cloneValue(this.unwrapListValue(inputValue));
5201
+ this.assignReference(reference, nextCollection, context.currentValue);
5202
+ return inputValue;
5203
+ }
5204
+ resolveCollectionReference(reference, inputValue, context) {
5205
+ const resolved = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5206
+ const widgetCollection = this.getWidgetCollection(this.asWidgetState(resolved));
5207
+ const collection = Array.isArray(resolved) ? resolved : widgetCollection;
5208
+ if (!collection) {
5209
+ return null;
5210
+ }
5211
+ return collection.map((entry) => this.unwrapListValue(entry));
5212
+ }
5213
+ getWidgetCollection(state) {
5214
+ if (!state) {
5215
+ return null;
5216
+ }
5217
+ if (state.widget === "list" || state.widget === "grid-view") {
5218
+ return state.elements ?? null;
5219
+ }
5220
+ if (state.widget === "listbox") {
5221
+ return state.listboxElements ?? null;
5222
+ }
5223
+ if (state.widget === "combobox") {
5224
+ return state.comboboxElements ?? null;
5225
+ }
5226
+ return null;
5227
+ }
5228
+ asWidgetState(value) {
5229
+ if (!value || typeof value !== "object") {
5230
+ return null;
5231
+ }
5232
+ return value;
5233
+ }
5131
5234
  isCurrentScopedReference(reference) {
5132
5235
  return reference === "current" || reference.startsWith("current.") || reference.startsWith("this.") || reference === "this";
5133
5236
  }
@@ -5175,6 +5278,21 @@ var ActionRuntime = class {
5175
5278
  function isIfElseArgs(value) {
5176
5279
  return typeof value === "object" && value !== null && !Array.isArray(value);
5177
5280
  }
5281
+ function resolveActionDefinition(actionsMap, actionName) {
5282
+ const directMatch = actionsMap[actionName];
5283
+ if (Array.isArray(directMatch)) {
5284
+ return directMatch;
5285
+ }
5286
+ const segments = actionName.split(".").filter(Boolean);
5287
+ let current = actionsMap;
5288
+ for (const segment of segments) {
5289
+ if (typeof current !== "object" || current === null || !(segment in current)) {
5290
+ return void 0;
5291
+ }
5292
+ current = current[segment];
5293
+ }
5294
+ return Array.isArray(current) ? current : void 0;
5295
+ }
5178
5296
  function isListElementLike(value) {
5179
5297
  return typeof value === "object" && value !== null && "kind" in value && value.kind === "list-element" && "listId" in value && typeof value.listId === "string" && "index" in value && typeof value.index === "number" && "descriptor" in value;
5180
5298
  }
@@ -7387,10 +7505,10 @@ var RuntimeRenderer = class {
7387
7505
  rerenderRoot: () => this.rerenderRoot(),
7388
7506
  dispatchWidgetEvent: (node, eventName, key, inputValue, pointer) => this.actionRuntime.dispatchWidgetEvent(node, eventName, key, inputValue, pointer),
7389
7507
  executeRequest: (requestName, currentValue) => this.networkRuntime.executeRequest(requestName, currentValue),
7390
- resolveReference: (reference, currentValue, responseValue) => this.referenceRuntime.resolveReference(reference, currentValue, responseValue),
7391
- isEmptyReference: (reference, currentValue, responseValue) => this.referenceRuntime.isEmptyReference(reference, currentValue, responseValue),
7508
+ resolveReference: (reference, currentValue, responseValue, inputValue) => this.referenceRuntime.resolveReference(reference, currentValue, responseValue, inputValue),
7509
+ isEmptyReference: (reference, currentValue, responseValue, inputValue) => this.referenceRuntime.isEmptyReference(reference, currentValue, responseValue, inputValue),
7392
7510
  assignReference: (reference, inputValue, currentValue, options2) => this.referenceRuntime.assignReference(reference, inputValue, currentValue, options2),
7393
- resolveMappedValue: (template, currentValue, responseValue) => this.referenceRuntime.resolveMappedValue(template, currentValue, responseValue),
7511
+ resolveMappedValue: (template, currentValue, responseValue, inputValue) => this.referenceRuntime.resolveMappedValue(template, currentValue, responseValue, inputValue),
7394
7512
  setWidgetEnabled: (widgetId, enabled) => this.setWidgetEnabled(widgetId, enabled),
7395
7513
  setWidgetVisible: (widgetId, visible) => this.setWidgetVisible(widgetId, visible),
7396
7514
  clearWidget: (widgetId) => this.clearWidget(widgetId),
@@ -7479,7 +7597,11 @@ var RuntimeRenderer = class {
7479
7597
  const nextIsMobile = isMobileViewport();
7480
7598
  if (nextIsMobile !== previousIsMobile) {
7481
7599
  previousIsMobile = nextIsMobile;
7482
- renderSync();
7600
+ void this.handleLayoutSwitch(nextIsMobile).catch((error) => {
7601
+ logRuntimeError("handleLayoutSwitch", error, {
7602
+ nextIsMobile
7603
+ });
7604
+ });
7483
7605
  }
7484
7606
  };
7485
7607
  window.addEventListener("resize", handleResize);
@@ -7544,6 +7666,11 @@ var RuntimeRenderer = class {
7544
7666
  }
7545
7667
  return Promise.resolve();
7546
7668
  }
7669
+ async handleLayoutSwitch(nextIsMobile) {
7670
+ await this.rerenderRoot();
7671
+ await this.runSystemEvent(nextIsMobile ? "onLayoutSwitchToMobile" : "onLayoutSwitchToDesktop");
7672
+ await this.rerenderRoot();
7673
+ }
7547
7674
  async runSystemEvent(eventName) {
7548
7675
  const actions = this.systemEvents[eventName];
7549
7676
  if (!actions?.length) {
@@ -9076,6 +9203,39 @@ function renderApp(root, description, options = {}) {
9076
9203
  }
9077
9204
 
9078
9205
  // src/lib/resource-manager.ts
9206
+ function isRequestDefinitionLike2(value) {
9207
+ return typeof value === "object" && value !== null && "request" in value && "name" in value;
9208
+ }
9209
+ function flattenActionMap(input, prefix = "") {
9210
+ const result = {};
9211
+ if (!input) {
9212
+ return result;
9213
+ }
9214
+ for (const [key, value] of Object.entries(input)) {
9215
+ const qualifiedName = prefix ? `${prefix}.${key}` : key;
9216
+ if (Array.isArray(value)) {
9217
+ result[qualifiedName] = value;
9218
+ continue;
9219
+ }
9220
+ Object.assign(result, flattenActionMap(value, qualifiedName));
9221
+ }
9222
+ return result;
9223
+ }
9224
+ function flattenRequestMap(input, prefix = "") {
9225
+ const result = {};
9226
+ if (!input) {
9227
+ return result;
9228
+ }
9229
+ for (const [key, value] of Object.entries(input)) {
9230
+ const qualifiedName = prefix ? `${prefix}.${key}` : key;
9231
+ if (isRequestDefinitionLike2(value)) {
9232
+ result[qualifiedName] = value;
9233
+ continue;
9234
+ }
9235
+ Object.assign(result, flattenRequestMap(value, qualifiedName));
9236
+ }
9237
+ return result;
9238
+ }
9079
9239
  var ResourceManager = class {
9080
9240
  ui = /* @__PURE__ */ new Map();
9081
9241
  actions = {};
@@ -9089,8 +9249,8 @@ var ResourceManager = class {
9089
9249
  for (const [key, value] of Object.entries(input.ui ?? {})) {
9090
9250
  this.ui.set(key, value);
9091
9251
  }
9092
- this.actions = { ...input.actions ?? {} };
9093
- this.requests = { ...input.requests ?? {} };
9252
+ this.actions = flattenActionMap(input.actions);
9253
+ this.requests = flattenRequestMap(input.requests);
9094
9254
  this.routes = Array.isArray(input.routes) ? input.routes.map((route) => ({ ...route })) : Array.isArray(input.routes?.routes) ? input.routes.routes.map((route) => ({ ...route })) : [];
9095
9255
  this.sse = { ...input.sse ?? {} };
9096
9256
  this.systemEvents = { ...input.systemEvents ?? {} };
@@ -1,4 +1,4 @@
1
- import type { ActionDefinition, ActionMap, DescriptionNode, WidgetEventName, WidgetState } from './types.js';
1
+ import type { ActionDefinition, ActionMapInput, DescriptionNode, WidgetEventName, WidgetState } from './types.js';
2
2
  export type ActionExecutionContext = {
3
3
  currentValue: unknown;
4
4
  responseValue?: unknown;
@@ -11,7 +11,7 @@ export type ActionExecutionContext = {
11
11
  };
12
12
  type ActionRuntimeOptions = {
13
13
  debugLogging: boolean;
14
- actionsMap: ActionMap;
14
+ actionsMap: ActionMapInput;
15
15
  actionFunctions: Record<string, () => unknown>;
16
16
  nodeById: Map<string, DescriptionNode>;
17
17
  stateById: Map<string, WidgetState>;
@@ -22,12 +22,12 @@ type ActionRuntimeOptions = {
22
22
  y: number;
23
23
  } | null) => Promise<void>;
24
24
  executeRequest: (requestName: string, currentValue: unknown) => Promise<unknown>;
25
- resolveReference: (reference: string, currentValue: unknown, responseValue: unknown) => unknown;
26
- isEmptyReference: (reference: string, currentValue: unknown, responseValue: unknown) => boolean;
25
+ resolveReference: (reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown) => unknown;
26
+ isEmptyReference: (reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown) => boolean;
27
27
  assignReference: (reference: string, inputValue: unknown, currentValue: unknown, options?: {
28
28
  cookieTtl?: unknown;
29
29
  }) => void;
30
- resolveMappedValue: (template: unknown, currentValue: unknown, responseValue: unknown) => unknown;
30
+ resolveMappedValue: (template: unknown, currentValue: unknown, responseValue: unknown, inputValue?: unknown) => unknown;
31
31
  setWidgetEnabled: (widgetId: string, enabled: boolean) => void;
32
32
  setWidgetVisible: (widgetId: string, visible: boolean) => void;
33
33
  clearWidget: (widgetId: string) => void;
@@ -124,6 +124,11 @@ export declare class ActionRuntime {
124
124
  private getCurrentListState;
125
125
  private cloneValue;
126
126
  private stringifyValue;
127
+ private getCollectionBoundaryByReference;
128
+ private setCollectionBoundaryByReference;
129
+ private resolveCollectionReference;
130
+ private getWidgetCollection;
131
+ private asWidgetState;
127
132
  private isCurrentScopedReference;
128
133
  private countValue;
129
134
  private toNumber;
@@ -1,11 +1,11 @@
1
- import type { ActionDefinition, PrimitiveRequestType, RequestMap, RequestSchema, SseConfig } from './types.js';
1
+ import type { ActionDefinition, PrimitiveRequestType, RequestMapInput, RequestSchema, SseConfig } from './types.js';
2
2
  type ActionRunner = (actions: ActionDefinition[], inputValue: unknown, context: {
3
3
  currentValue: unknown;
4
4
  responseValue?: unknown;
5
5
  }) => Promise<unknown>;
6
6
  type NetworkRuntimeOptions = {
7
7
  debugLogging: boolean;
8
- requestsMap: RequestMap;
8
+ requestsMap: RequestMapInput;
9
9
  sseConfigs: SseConfig[];
10
10
  backendUrl?: string;
11
11
  eventSources: EventSource[];
@@ -16,8 +16,8 @@ type ReferenceRuntimeHost = {
16
16
  export declare class ReferenceRuntime {
17
17
  private readonly host;
18
18
  constructor(host: ReferenceRuntimeHost);
19
- isEmptyReference(reference: string, currentValue: unknown, responseValue: unknown): boolean;
20
- resolveReference(reference: string, currentValue: unknown, responseValue: unknown): unknown;
19
+ isEmptyReference(reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown): boolean;
20
+ resolveReference(reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown): unknown;
21
21
  resolveCurrentReference(reference: string, currentValue: unknown): unknown;
22
22
  readWidgetField(state: WidgetState, field: string): unknown;
23
23
  assignReference(reference: string, inputValue: unknown, currentValue: unknown, options?: {
@@ -25,7 +25,7 @@ export declare class ReferenceRuntime {
25
25
  }): void;
26
26
  private assignCurrentReference;
27
27
  clearListElementState(listKey: string): void;
28
- resolveMappedValue(template: unknown, currentValue: unknown, responseValue: unknown): unknown;
28
+ resolveMappedValue(template: unknown, currentValue: unknown, responseValue: unknown, inputValue?: unknown): unknown;
29
29
  isListElementContext(value: unknown): value is ListElementContext;
30
30
  findNamedWidget(node: DescriptionNode | undefined, name: string, currentValue?: unknown): DescriptionNode | null;
31
31
  private resolveListDescriptorNode;
@@ -1,8 +1,8 @@
1
- import type { ActionMap, DescriptionNode, I18nMap, RequestMap, RouteDefinition, RoutesConfigInput, SseConfig, SystemEventsMap, StyleMap } from './types.js';
1
+ import type { ActionMap, ActionMapInput, DescriptionNode, I18nMap, RequestMap, RequestMapInput, RouteDefinition, RoutesConfigInput, SseConfig, SystemEventsMap, StyleMap } from './types.js';
2
2
  export type ResourceManagerInput = {
3
3
  ui?: Record<string, DescriptionNode>;
4
- actions?: ActionMap;
5
- requests?: RequestMap;
4
+ actions?: ActionMapInput;
5
+ requests?: RequestMapInput;
6
6
  routes?: RoutesConfigInput;
7
7
  sse?: Record<string, SseConfig>;
8
8
  systemEvents?: SystemEventsMap;
@@ -4,7 +4,7 @@ export type TextAlign = 'left' | 'center' | 'right';
4
4
  export type VerticalAlign = 'top' | 'center' | 'bottom';
5
5
  export type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
6
6
  export type WidgetEventName = 'onClick' | 'onUserValueChange' | 'onRefresh' | 'onEnter' | 'onShiftEnter' | 'onControlEnter' | 'onPaste';
7
- export type SystemEventName = 'onBeforeRender' | 'onAfterRender' | 'onBeforeNavigate' | 'onAfterNavigate' | 'onSpeechDetected' | 'onRecordingStarted' | 'onRecordingStopped' | 'onRecordingError' | 'onListeningError' | 'onListeringError' | 'onPlayFinished' | 'onPlayingStopped';
7
+ export type SystemEventName = 'onBeforeRender' | 'onAfterRender' | 'onBeforeNavigate' | 'onAfterNavigate' | 'onLayoutSwitchToMobile' | 'onLayoutSwitchToDesktop' | 'onSpeechDetected' | 'onRecordingStarted' | 'onRecordingStopped' | 'onRecordingError' | 'onListeningError' | 'onListeringError' | 'onPlayFinished' | 'onPlayingStopped';
8
8
  export type PrimitiveRequestType = 'int' | 'float' | 'boolean' | 'string';
9
9
  export type RouteDefinition = {
10
10
  path: string;
@@ -93,6 +93,12 @@ export type StyleMap = Record<string, string>;
93
93
  export type I18nMap = Record<string, Record<string, string>>;
94
94
  export type ActionMap = Record<string, ActionDefinition[]>;
95
95
  export type RequestMap = Record<string, RequestDefinition>;
96
+ export type ActionMapInput = {
97
+ [key: string]: ActionDefinition[] | ActionMapInput;
98
+ };
99
+ export type RequestMapInput = {
100
+ [key: string]: RequestDefinition | RequestMapInput;
101
+ };
96
102
  export type SseConfigInput = SseConfig | SseConfig[];
97
103
  export type SystemEventsMap = Partial<Record<SystemEventName, ActionDefinition[]>>;
98
104
  export type WidgetState = {
@@ -145,8 +151,8 @@ export type RenderJsonOptions = {
145
151
  language?: string;
146
152
  theme?: Theme;
147
153
  debugLogging?: boolean;
148
- actionsMap?: ActionMap;
149
- requestsMap?: RequestMap;
154
+ actionsMap?: ActionMapInput;
155
+ requestsMap?: RequestMapInput;
150
156
  sseConfigs?: SseConfigInput;
151
157
  systemEvents?: SystemEventsMap;
152
158
  routes?: RoutesConfigInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vortexm/vjt",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",