@arronqzy/blueprint-dsl 1.0.9 → 1.0.10

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.d.cts CHANGED
@@ -327,6 +327,40 @@ declare function validateJsonString(jsonString: string): {
327
327
  };
328
328
  declare function parseJsonConfig(config: JsonNodeConfig): unknown;
329
329
 
330
+ type StorageKind = "session" | "local";
331
+ type StorageReadConfig = {
332
+ storage: StorageKind;
333
+ key: string;
334
+ };
335
+ type StorageSetConfig = {
336
+ storages: StorageKind[];
337
+ key: string;
338
+ value: string;
339
+ };
340
+ type StorageNodeConfig = {
341
+ read: StorageReadConfig;
342
+ set: StorageSetConfig;
343
+ };
344
+ declare const STORAGE_KINDS: StorageKind[];
345
+ declare const DEFAULT_STORAGE_NODE_CONFIG: StorageNodeConfig;
346
+ type WebStorageLike = {
347
+ getItem(key: string): string | null;
348
+ setItem(key: string, value: string): void;
349
+ };
350
+ type StorageAccessors = {
351
+ session?: WebStorageLike | null;
352
+ local?: WebStorageLike | null;
353
+ };
354
+ declare function uniqueStorageKinds(kinds?: readonly unknown[]): StorageKind[];
355
+ declare function normalizeStorageConfig(config?: Partial<StorageNodeConfig> | null): StorageNodeConfig;
356
+ declare function isStorageReadConfigured(config: Pick<StorageNodeConfig, "read">): boolean;
357
+ declare function isStorageSetConfigured(config: Pick<StorageNodeConfig, "set">): boolean;
358
+ declare function resolveStorageWriteValue(template: string, scope: unknown): unknown;
359
+ declare function serializeStorageValue(value: unknown): string;
360
+ declare function deserializeStorageValue(raw: string | null): unknown;
361
+ /** 先设置再读取。未配置设置则不写入;未配置读取则返回空。 */
362
+ declare function executeStorageConfig(config: StorageNodeConfig, incomingScope: unknown, accessors?: StorageAccessors | null): unknown;
363
+
330
364
  type LogicNodeConfig = {
331
365
  /** 用户手写的 update(input) 函数脚本 */
332
366
  sourceCode: string;
@@ -524,6 +558,7 @@ declare const DEFAULT_LOGIC_NODE_TYPE = "Logic";
524
558
  declare const LIFECYCLE_NODE_TYPE = "Lifecycle";
525
559
  declare const FETCH_NODE_TYPE = "DataFetch";
526
560
  declare const JSON_NODE_TYPE = "JsonNode";
561
+ declare const STORAGE_NODE_TYPE = "StorageNode";
527
562
  declare const CLOCK_NODE_TYPE = "Clock";
528
563
  declare const AND_NODE_TYPE = "AndLogic";
529
564
  declare const VIEW_NODE_TYPE = "ViewBind";
@@ -537,6 +572,8 @@ declare const lifecycleNodeDefinition: NodeDefinition;
537
572
  declare const fetchNodeDefinition: NodeDefinition;
538
573
  /** JSON 解析:收到真信号后将配置的 JSON 转为 object 输出 */
539
574
  declare const jsonNodeDefinition: NodeDefinition;
575
+ /** 存储节点:收到真信号后先写入再读取 sessionStorage / localStorage */
576
+ declare const storageNodeDefinition: NodeDefinition;
540
577
  /** 时钟节点:收到真信号后按间隔输出含当前时间的真信号 */
541
578
  declare const clockNodeDefinition: NodeDefinition;
542
579
  /** 并运算:两路输入均为真时输出真信号;单端口多连线按「或」合并 */
@@ -561,6 +598,7 @@ type RunnableGraphNode = {
561
598
  viewElementIds?: string[];
562
599
  fetchConfig?: FetchRequestConfig;
563
600
  jsonConfig?: JsonNodeConfig;
601
+ storageConfig?: StorageNodeConfig;
564
602
  logicConfig?: LogicNodeConfig;
565
603
  clockConfig?: ClockNodeConfig;
566
604
  eventConfig?: ViewEventNodeConfig;
@@ -674,6 +712,7 @@ declare class BlueprintGraphRunner {
674
712
  private registerFetchBehavior;
675
713
  private registerLogicBehavior;
676
714
  private registerJsonBehavior;
715
+ private registerStorageBehavior;
677
716
  private registerClockBehavior;
678
717
  private registerAndBehavior;
679
718
  private registerViewBindBehavior;
@@ -736,4 +775,4 @@ declare function isClockNodeActive(nodeId: string): boolean;
736
775
  declare function getActiveClockNodeIds(): string[];
737
776
  declare function subscribeActiveClockNodes(listener: () => void): () => boolean;
738
777
 
739
- export { AND_NODE_TYPE, BLUEPRINT_ACTIVATION_INPUT_KEY, BLUEPRINT_CALL_STACK_KEY, BLUEPRINT_NODE_TYPE, type Behavior, type BehaviorContext, type BehaviorFn, BehaviorRegistry, type BlueprintCycleCheckOptions, type BlueprintCycleCheckResult, BlueprintCycleError, BlueprintGraphRunner, type BlueprintNodeOutputs, type BlueprintRefOutput, CLOCK_NODE_TYPE, type ClockNodeConfig, type ClockSignalOutput, DEFAULT_CLOCK_NODE_CONFIG, DEFAULT_FETCH_REQUEST_CONFIG, DEFAULT_JSON_NODE_CONFIG, DEFAULT_LOGIC_NODE_CONFIG, DEFAULT_LOGIC_NODE_TYPE, DEFAULT_VIEW_EVENT_NODE_CONFIG, EVENT_NODE_TYPE, type ExecuteFetchOptions, type ExecutionRunRecord, type ExecutionToken, type ExecutionTraceEntry, Executor, type ExecutorDeps, FETCH_CACHES, FETCH_CREDENTIALS, FETCH_HTTP_METHODS, FETCH_MODES, FETCH_NODE_TYPE, FETCH_REDIRECTS, FETCH_RESPONSE_TYPES, FETCH_SCOPE_AUTOCOMPLETE_FALLBACK, type FalseSignal, type FetchHttpMethod, type FetchRequestConfig, type FetchResponseType, type FetchResultValue, type FetchUrlInputMode, type IncomingGraphEdge, type IncomingNodeScope, type IncomingNodeScopeEntry, type IncomingNodeSource, JSON_NODE_TYPE, type JsonNodeConfig, LIFECYCLE_NODE_TYPE, LIFECYCLE_SIGNAL_KEY, type LibraryBlueprintResolver, type LifecycleSignal, type LogicNodeConfig, type NodeDefinition, type NodeSignal, PAGE_LIFECYCLE_LABELS, PAGE_LIFECYCLE_PHASES, type PageLifecyclePhase, type ParsedSwaggerDocument, type PortSpec, type RunnableGraph, type RunnableGraphEdge, type RunnableGraphNode, type Scope, type ScopeAutocompleteState, type SwaggerApiEndpoint, type TrueSignal, UI_EVENT_PAYLOAD_KEY, VIEW_EVENT_SIGNAL_KEY, VIEW_EVENT_TYPES, VIEW_NODE_TYPE, type Value, type ViewEventNodeConfig, type ViewEventNodeSnapshot, type ViewEventSignal, type ViewEventSnapshot, type ViewEventType, type ViewScopeUpdateCallback, abortClockNode, abortClockSession, andLogicNodeDefinition, applyFetchConfigScope, applyScopeAutocompleteSelection, assertNoBlueprintReferenceCycle, blueprintNodeDefinition, buildClockSessionKey, buildClockSignalValue, buildEndpointFullUrl, buildEndpointSuggestions, buildIncomingNodeScope, buildScopeExpression, clearClockSessionAbort, clockNodeDefinition, collectArmedViewEventBindings, collectArmedViewEventNodeIds, collectBlueprintLibraryRefs, collectIncomingNodeScopeEntries, collectViewEventBindings, combinePortSignalsOr, createClockOutputValue, createFalseSignal, createIncomingNodeScopeEntry, createLifecycleSignal, createTraceEntryId, createTrueSignal, createViewEventSignal, defaultLogicNodeDefinition, detectBlueprintReferenceCycle, detectRuntimeBlueprintCycle, draftFetchHeadersText, evaluateScopeExpression, evaluateScopeTemplate, evaluateScopeTemplateInJson, executeFetch, executeLogicConfig, fetchConfigHasScopeTemplate, fetchNodeDefinition, filterEndpointSuggestions, formatBlueprintCycleMessage, formatClockTime, getActiveClockNodeIds, getClockTickDelayOffsetMs, getClockTickWaitMs, getFetchBodyValidationError, getFetchHeadersValidationError, getNodeDefinition, getScopeAutocompleteSuggestions, hasScopeTemplate, isClockNodeActive, isClockScheduleActive, isClockSessionAborted, isFalseSignal, isTrueSignal, isViewEventType, isWholeScopeExpression, jsonNodeDefinition, latestTraceOutputsByNode, lifecycleNodeDefinition, looksLikeJsonText, nodeDefinitionRegistry, normalizeClockConfig, normalizeFetchRequestConfig, normalizeViewEventConfig, parseFetchHeadersJson, parseJsonConfig, parseJsonText, parseScopeAutocomplete, parseSwaggerDocument, registerDefaultBehaviors, resolveBlueprintCallStack, resolveFetchBody, resolveFetchHeaders, resolveFetchIncomingScope, resolveFetchRequestUrl, resolveFetchScopeAutocompleteRoot, scheduleClockOutputs, serializeTraceValue, snapshotDomEvent, snapshotViewEventNode, startClockSchedule, stopAllClockSchedules, stopClockSchedule, stringifyScopeValue, subscribeActiveClockNodes, validateClockScheduleConfig, validateFetchJsonText, validateJsonString, validateLogicSourceCode, viewBindNodeDefinition, viewEventNodeDefinition };
778
+ export { AND_NODE_TYPE, BLUEPRINT_ACTIVATION_INPUT_KEY, BLUEPRINT_CALL_STACK_KEY, BLUEPRINT_NODE_TYPE, type Behavior, type BehaviorContext, type BehaviorFn, BehaviorRegistry, type BlueprintCycleCheckOptions, type BlueprintCycleCheckResult, BlueprintCycleError, BlueprintGraphRunner, type BlueprintNodeOutputs, type BlueprintRefOutput, CLOCK_NODE_TYPE, type ClockNodeConfig, type ClockSignalOutput, DEFAULT_CLOCK_NODE_CONFIG, DEFAULT_FETCH_REQUEST_CONFIG, DEFAULT_JSON_NODE_CONFIG, DEFAULT_LOGIC_NODE_CONFIG, DEFAULT_LOGIC_NODE_TYPE, DEFAULT_STORAGE_NODE_CONFIG, DEFAULT_VIEW_EVENT_NODE_CONFIG, EVENT_NODE_TYPE, type ExecuteFetchOptions, type ExecutionRunRecord, type ExecutionToken, type ExecutionTraceEntry, Executor, type ExecutorDeps, FETCH_CACHES, FETCH_CREDENTIALS, FETCH_HTTP_METHODS, FETCH_MODES, FETCH_NODE_TYPE, FETCH_REDIRECTS, FETCH_RESPONSE_TYPES, FETCH_SCOPE_AUTOCOMPLETE_FALLBACK, type FalseSignal, type FetchHttpMethod, type FetchRequestConfig, type FetchResponseType, type FetchResultValue, type FetchUrlInputMode, type IncomingGraphEdge, type IncomingNodeScope, type IncomingNodeScopeEntry, type IncomingNodeSource, JSON_NODE_TYPE, type JsonNodeConfig, LIFECYCLE_NODE_TYPE, LIFECYCLE_SIGNAL_KEY, type LibraryBlueprintResolver, type LifecycleSignal, type LogicNodeConfig, type NodeDefinition, type NodeSignal, PAGE_LIFECYCLE_LABELS, PAGE_LIFECYCLE_PHASES, type PageLifecyclePhase, type ParsedSwaggerDocument, type PortSpec, type RunnableGraph, type RunnableGraphEdge, type RunnableGraphNode, STORAGE_KINDS, STORAGE_NODE_TYPE, type Scope, type ScopeAutocompleteState, type StorageAccessors, type StorageKind, type StorageNodeConfig, type StorageReadConfig, type StorageSetConfig, type SwaggerApiEndpoint, type TrueSignal, UI_EVENT_PAYLOAD_KEY, VIEW_EVENT_SIGNAL_KEY, VIEW_EVENT_TYPES, VIEW_NODE_TYPE, type Value, type ViewEventNodeConfig, type ViewEventNodeSnapshot, type ViewEventSignal, type ViewEventSnapshot, type ViewEventType, type ViewScopeUpdateCallback, type WebStorageLike, abortClockNode, abortClockSession, andLogicNodeDefinition, applyFetchConfigScope, applyScopeAutocompleteSelection, assertNoBlueprintReferenceCycle, blueprintNodeDefinition, buildClockSessionKey, buildClockSignalValue, buildEndpointFullUrl, buildEndpointSuggestions, buildIncomingNodeScope, buildScopeExpression, clearClockSessionAbort, clockNodeDefinition, collectArmedViewEventBindings, collectArmedViewEventNodeIds, collectBlueprintLibraryRefs, collectIncomingNodeScopeEntries, collectViewEventBindings, combinePortSignalsOr, createClockOutputValue, createFalseSignal, createIncomingNodeScopeEntry, createLifecycleSignal, createTraceEntryId, createTrueSignal, createViewEventSignal, defaultLogicNodeDefinition, deserializeStorageValue, detectBlueprintReferenceCycle, detectRuntimeBlueprintCycle, draftFetchHeadersText, evaluateScopeExpression, evaluateScopeTemplate, evaluateScopeTemplateInJson, executeFetch, executeLogicConfig, executeStorageConfig, fetchConfigHasScopeTemplate, fetchNodeDefinition, filterEndpointSuggestions, formatBlueprintCycleMessage, formatClockTime, getActiveClockNodeIds, getClockTickDelayOffsetMs, getClockTickWaitMs, getFetchBodyValidationError, getFetchHeadersValidationError, getNodeDefinition, getScopeAutocompleteSuggestions, hasScopeTemplate, isClockNodeActive, isClockScheduleActive, isClockSessionAborted, isFalseSignal, isStorageReadConfigured, isStorageSetConfigured, isTrueSignal, isViewEventType, isWholeScopeExpression, jsonNodeDefinition, latestTraceOutputsByNode, lifecycleNodeDefinition, looksLikeJsonText, nodeDefinitionRegistry, normalizeClockConfig, normalizeFetchRequestConfig, normalizeStorageConfig, normalizeViewEventConfig, parseFetchHeadersJson, parseJsonConfig, parseJsonText, parseScopeAutocomplete, parseSwaggerDocument, registerDefaultBehaviors, resolveBlueprintCallStack, resolveFetchBody, resolveFetchHeaders, resolveFetchIncomingScope, resolveFetchRequestUrl, resolveFetchScopeAutocompleteRoot, resolveStorageWriteValue, scheduleClockOutputs, serializeStorageValue, serializeTraceValue, snapshotDomEvent, snapshotViewEventNode, startClockSchedule, stopAllClockSchedules, stopClockSchedule, storageNodeDefinition, stringifyScopeValue, subscribeActiveClockNodes, uniqueStorageKinds, validateClockScheduleConfig, validateFetchJsonText, validateJsonString, validateLogicSourceCode, viewBindNodeDefinition, viewEventNodeDefinition };
package/dist/index.d.ts CHANGED
@@ -327,6 +327,40 @@ declare function validateJsonString(jsonString: string): {
327
327
  };
328
328
  declare function parseJsonConfig(config: JsonNodeConfig): unknown;
329
329
 
330
+ type StorageKind = "session" | "local";
331
+ type StorageReadConfig = {
332
+ storage: StorageKind;
333
+ key: string;
334
+ };
335
+ type StorageSetConfig = {
336
+ storages: StorageKind[];
337
+ key: string;
338
+ value: string;
339
+ };
340
+ type StorageNodeConfig = {
341
+ read: StorageReadConfig;
342
+ set: StorageSetConfig;
343
+ };
344
+ declare const STORAGE_KINDS: StorageKind[];
345
+ declare const DEFAULT_STORAGE_NODE_CONFIG: StorageNodeConfig;
346
+ type WebStorageLike = {
347
+ getItem(key: string): string | null;
348
+ setItem(key: string, value: string): void;
349
+ };
350
+ type StorageAccessors = {
351
+ session?: WebStorageLike | null;
352
+ local?: WebStorageLike | null;
353
+ };
354
+ declare function uniqueStorageKinds(kinds?: readonly unknown[]): StorageKind[];
355
+ declare function normalizeStorageConfig(config?: Partial<StorageNodeConfig> | null): StorageNodeConfig;
356
+ declare function isStorageReadConfigured(config: Pick<StorageNodeConfig, "read">): boolean;
357
+ declare function isStorageSetConfigured(config: Pick<StorageNodeConfig, "set">): boolean;
358
+ declare function resolveStorageWriteValue(template: string, scope: unknown): unknown;
359
+ declare function serializeStorageValue(value: unknown): string;
360
+ declare function deserializeStorageValue(raw: string | null): unknown;
361
+ /** 先设置再读取。未配置设置则不写入;未配置读取则返回空。 */
362
+ declare function executeStorageConfig(config: StorageNodeConfig, incomingScope: unknown, accessors?: StorageAccessors | null): unknown;
363
+
330
364
  type LogicNodeConfig = {
331
365
  /** 用户手写的 update(input) 函数脚本 */
332
366
  sourceCode: string;
@@ -524,6 +558,7 @@ declare const DEFAULT_LOGIC_NODE_TYPE = "Logic";
524
558
  declare const LIFECYCLE_NODE_TYPE = "Lifecycle";
525
559
  declare const FETCH_NODE_TYPE = "DataFetch";
526
560
  declare const JSON_NODE_TYPE = "JsonNode";
561
+ declare const STORAGE_NODE_TYPE = "StorageNode";
527
562
  declare const CLOCK_NODE_TYPE = "Clock";
528
563
  declare const AND_NODE_TYPE = "AndLogic";
529
564
  declare const VIEW_NODE_TYPE = "ViewBind";
@@ -537,6 +572,8 @@ declare const lifecycleNodeDefinition: NodeDefinition;
537
572
  declare const fetchNodeDefinition: NodeDefinition;
538
573
  /** JSON 解析:收到真信号后将配置的 JSON 转为 object 输出 */
539
574
  declare const jsonNodeDefinition: NodeDefinition;
575
+ /** 存储节点:收到真信号后先写入再读取 sessionStorage / localStorage */
576
+ declare const storageNodeDefinition: NodeDefinition;
540
577
  /** 时钟节点:收到真信号后按间隔输出含当前时间的真信号 */
541
578
  declare const clockNodeDefinition: NodeDefinition;
542
579
  /** 并运算:两路输入均为真时输出真信号;单端口多连线按「或」合并 */
@@ -561,6 +598,7 @@ type RunnableGraphNode = {
561
598
  viewElementIds?: string[];
562
599
  fetchConfig?: FetchRequestConfig;
563
600
  jsonConfig?: JsonNodeConfig;
601
+ storageConfig?: StorageNodeConfig;
564
602
  logicConfig?: LogicNodeConfig;
565
603
  clockConfig?: ClockNodeConfig;
566
604
  eventConfig?: ViewEventNodeConfig;
@@ -674,6 +712,7 @@ declare class BlueprintGraphRunner {
674
712
  private registerFetchBehavior;
675
713
  private registerLogicBehavior;
676
714
  private registerJsonBehavior;
715
+ private registerStorageBehavior;
677
716
  private registerClockBehavior;
678
717
  private registerAndBehavior;
679
718
  private registerViewBindBehavior;
@@ -736,4 +775,4 @@ declare function isClockNodeActive(nodeId: string): boolean;
736
775
  declare function getActiveClockNodeIds(): string[];
737
776
  declare function subscribeActiveClockNodes(listener: () => void): () => boolean;
738
777
 
739
- export { AND_NODE_TYPE, BLUEPRINT_ACTIVATION_INPUT_KEY, BLUEPRINT_CALL_STACK_KEY, BLUEPRINT_NODE_TYPE, type Behavior, type BehaviorContext, type BehaviorFn, BehaviorRegistry, type BlueprintCycleCheckOptions, type BlueprintCycleCheckResult, BlueprintCycleError, BlueprintGraphRunner, type BlueprintNodeOutputs, type BlueprintRefOutput, CLOCK_NODE_TYPE, type ClockNodeConfig, type ClockSignalOutput, DEFAULT_CLOCK_NODE_CONFIG, DEFAULT_FETCH_REQUEST_CONFIG, DEFAULT_JSON_NODE_CONFIG, DEFAULT_LOGIC_NODE_CONFIG, DEFAULT_LOGIC_NODE_TYPE, DEFAULT_VIEW_EVENT_NODE_CONFIG, EVENT_NODE_TYPE, type ExecuteFetchOptions, type ExecutionRunRecord, type ExecutionToken, type ExecutionTraceEntry, Executor, type ExecutorDeps, FETCH_CACHES, FETCH_CREDENTIALS, FETCH_HTTP_METHODS, FETCH_MODES, FETCH_NODE_TYPE, FETCH_REDIRECTS, FETCH_RESPONSE_TYPES, FETCH_SCOPE_AUTOCOMPLETE_FALLBACK, type FalseSignal, type FetchHttpMethod, type FetchRequestConfig, type FetchResponseType, type FetchResultValue, type FetchUrlInputMode, type IncomingGraphEdge, type IncomingNodeScope, type IncomingNodeScopeEntry, type IncomingNodeSource, JSON_NODE_TYPE, type JsonNodeConfig, LIFECYCLE_NODE_TYPE, LIFECYCLE_SIGNAL_KEY, type LibraryBlueprintResolver, type LifecycleSignal, type LogicNodeConfig, type NodeDefinition, type NodeSignal, PAGE_LIFECYCLE_LABELS, PAGE_LIFECYCLE_PHASES, type PageLifecyclePhase, type ParsedSwaggerDocument, type PortSpec, type RunnableGraph, type RunnableGraphEdge, type RunnableGraphNode, type Scope, type ScopeAutocompleteState, type SwaggerApiEndpoint, type TrueSignal, UI_EVENT_PAYLOAD_KEY, VIEW_EVENT_SIGNAL_KEY, VIEW_EVENT_TYPES, VIEW_NODE_TYPE, type Value, type ViewEventNodeConfig, type ViewEventNodeSnapshot, type ViewEventSignal, type ViewEventSnapshot, type ViewEventType, type ViewScopeUpdateCallback, abortClockNode, abortClockSession, andLogicNodeDefinition, applyFetchConfigScope, applyScopeAutocompleteSelection, assertNoBlueprintReferenceCycle, blueprintNodeDefinition, buildClockSessionKey, buildClockSignalValue, buildEndpointFullUrl, buildEndpointSuggestions, buildIncomingNodeScope, buildScopeExpression, clearClockSessionAbort, clockNodeDefinition, collectArmedViewEventBindings, collectArmedViewEventNodeIds, collectBlueprintLibraryRefs, collectIncomingNodeScopeEntries, collectViewEventBindings, combinePortSignalsOr, createClockOutputValue, createFalseSignal, createIncomingNodeScopeEntry, createLifecycleSignal, createTraceEntryId, createTrueSignal, createViewEventSignal, defaultLogicNodeDefinition, detectBlueprintReferenceCycle, detectRuntimeBlueprintCycle, draftFetchHeadersText, evaluateScopeExpression, evaluateScopeTemplate, evaluateScopeTemplateInJson, executeFetch, executeLogicConfig, fetchConfigHasScopeTemplate, fetchNodeDefinition, filterEndpointSuggestions, formatBlueprintCycleMessage, formatClockTime, getActiveClockNodeIds, getClockTickDelayOffsetMs, getClockTickWaitMs, getFetchBodyValidationError, getFetchHeadersValidationError, getNodeDefinition, getScopeAutocompleteSuggestions, hasScopeTemplate, isClockNodeActive, isClockScheduleActive, isClockSessionAborted, isFalseSignal, isTrueSignal, isViewEventType, isWholeScopeExpression, jsonNodeDefinition, latestTraceOutputsByNode, lifecycleNodeDefinition, looksLikeJsonText, nodeDefinitionRegistry, normalizeClockConfig, normalizeFetchRequestConfig, normalizeViewEventConfig, parseFetchHeadersJson, parseJsonConfig, parseJsonText, parseScopeAutocomplete, parseSwaggerDocument, registerDefaultBehaviors, resolveBlueprintCallStack, resolveFetchBody, resolveFetchHeaders, resolveFetchIncomingScope, resolveFetchRequestUrl, resolveFetchScopeAutocompleteRoot, scheduleClockOutputs, serializeTraceValue, snapshotDomEvent, snapshotViewEventNode, startClockSchedule, stopAllClockSchedules, stopClockSchedule, stringifyScopeValue, subscribeActiveClockNodes, validateClockScheduleConfig, validateFetchJsonText, validateJsonString, validateLogicSourceCode, viewBindNodeDefinition, viewEventNodeDefinition };
778
+ export { AND_NODE_TYPE, BLUEPRINT_ACTIVATION_INPUT_KEY, BLUEPRINT_CALL_STACK_KEY, BLUEPRINT_NODE_TYPE, type Behavior, type BehaviorContext, type BehaviorFn, BehaviorRegistry, type BlueprintCycleCheckOptions, type BlueprintCycleCheckResult, BlueprintCycleError, BlueprintGraphRunner, type BlueprintNodeOutputs, type BlueprintRefOutput, CLOCK_NODE_TYPE, type ClockNodeConfig, type ClockSignalOutput, DEFAULT_CLOCK_NODE_CONFIG, DEFAULT_FETCH_REQUEST_CONFIG, DEFAULT_JSON_NODE_CONFIG, DEFAULT_LOGIC_NODE_CONFIG, DEFAULT_LOGIC_NODE_TYPE, DEFAULT_STORAGE_NODE_CONFIG, DEFAULT_VIEW_EVENT_NODE_CONFIG, EVENT_NODE_TYPE, type ExecuteFetchOptions, type ExecutionRunRecord, type ExecutionToken, type ExecutionTraceEntry, Executor, type ExecutorDeps, FETCH_CACHES, FETCH_CREDENTIALS, FETCH_HTTP_METHODS, FETCH_MODES, FETCH_NODE_TYPE, FETCH_REDIRECTS, FETCH_RESPONSE_TYPES, FETCH_SCOPE_AUTOCOMPLETE_FALLBACK, type FalseSignal, type FetchHttpMethod, type FetchRequestConfig, type FetchResponseType, type FetchResultValue, type FetchUrlInputMode, type IncomingGraphEdge, type IncomingNodeScope, type IncomingNodeScopeEntry, type IncomingNodeSource, JSON_NODE_TYPE, type JsonNodeConfig, LIFECYCLE_NODE_TYPE, LIFECYCLE_SIGNAL_KEY, type LibraryBlueprintResolver, type LifecycleSignal, type LogicNodeConfig, type NodeDefinition, type NodeSignal, PAGE_LIFECYCLE_LABELS, PAGE_LIFECYCLE_PHASES, type PageLifecyclePhase, type ParsedSwaggerDocument, type PortSpec, type RunnableGraph, type RunnableGraphEdge, type RunnableGraphNode, STORAGE_KINDS, STORAGE_NODE_TYPE, type Scope, type ScopeAutocompleteState, type StorageAccessors, type StorageKind, type StorageNodeConfig, type StorageReadConfig, type StorageSetConfig, type SwaggerApiEndpoint, type TrueSignal, UI_EVENT_PAYLOAD_KEY, VIEW_EVENT_SIGNAL_KEY, VIEW_EVENT_TYPES, VIEW_NODE_TYPE, type Value, type ViewEventNodeConfig, type ViewEventNodeSnapshot, type ViewEventSignal, type ViewEventSnapshot, type ViewEventType, type ViewScopeUpdateCallback, type WebStorageLike, abortClockNode, abortClockSession, andLogicNodeDefinition, applyFetchConfigScope, applyScopeAutocompleteSelection, assertNoBlueprintReferenceCycle, blueprintNodeDefinition, buildClockSessionKey, buildClockSignalValue, buildEndpointFullUrl, buildEndpointSuggestions, buildIncomingNodeScope, buildScopeExpression, clearClockSessionAbort, clockNodeDefinition, collectArmedViewEventBindings, collectArmedViewEventNodeIds, collectBlueprintLibraryRefs, collectIncomingNodeScopeEntries, collectViewEventBindings, combinePortSignalsOr, createClockOutputValue, createFalseSignal, createIncomingNodeScopeEntry, createLifecycleSignal, createTraceEntryId, createTrueSignal, createViewEventSignal, defaultLogicNodeDefinition, deserializeStorageValue, detectBlueprintReferenceCycle, detectRuntimeBlueprintCycle, draftFetchHeadersText, evaluateScopeExpression, evaluateScopeTemplate, evaluateScopeTemplateInJson, executeFetch, executeLogicConfig, executeStorageConfig, fetchConfigHasScopeTemplate, fetchNodeDefinition, filterEndpointSuggestions, formatBlueprintCycleMessage, formatClockTime, getActiveClockNodeIds, getClockTickDelayOffsetMs, getClockTickWaitMs, getFetchBodyValidationError, getFetchHeadersValidationError, getNodeDefinition, getScopeAutocompleteSuggestions, hasScopeTemplate, isClockNodeActive, isClockScheduleActive, isClockSessionAborted, isFalseSignal, isStorageReadConfigured, isStorageSetConfigured, isTrueSignal, isViewEventType, isWholeScopeExpression, jsonNodeDefinition, latestTraceOutputsByNode, lifecycleNodeDefinition, looksLikeJsonText, nodeDefinitionRegistry, normalizeClockConfig, normalizeFetchRequestConfig, normalizeStorageConfig, normalizeViewEventConfig, parseFetchHeadersJson, parseJsonConfig, parseJsonText, parseScopeAutocomplete, parseSwaggerDocument, registerDefaultBehaviors, resolveBlueprintCallStack, resolveFetchBody, resolveFetchHeaders, resolveFetchIncomingScope, resolveFetchRequestUrl, resolveFetchScopeAutocompleteRoot, resolveStorageWriteValue, scheduleClockOutputs, serializeStorageValue, serializeTraceValue, snapshotDomEvent, snapshotViewEventNode, startClockSchedule, stopAllClockSchedules, stopClockSchedule, storageNodeDefinition, stringifyScopeValue, subscribeActiveClockNodes, uniqueStorageKinds, validateClockScheduleConfig, validateFetchJsonText, validateJsonString, validateLogicSourceCode, viewBindNodeDefinition, viewEventNodeDefinition };
package/dist/index.js CHANGED
@@ -810,6 +810,117 @@ function parseJsonConfig(config) {
810
810
  return result.value;
811
811
  }
812
812
 
813
+ // src/storage-config.ts
814
+ var STORAGE_KINDS = ["session", "local"];
815
+ var DEFAULT_STORAGE_NODE_CONFIG = {
816
+ read: { storage: "local", key: "" },
817
+ set: { storages: [], key: "", value: "" }
818
+ };
819
+ function isStorageKind(value) {
820
+ return value === "session" || value === "local";
821
+ }
822
+ function uniqueStorageKinds(kinds) {
823
+ const next = /* @__PURE__ */ new Set();
824
+ for (const kind of kinds ?? []) {
825
+ if (isStorageKind(kind)) next.add(kind);
826
+ }
827
+ return STORAGE_KINDS.filter((kind) => next.has(kind));
828
+ }
829
+ function normalizeStorageConfig(config) {
830
+ const read = config?.read;
831
+ const set = config?.set;
832
+ return {
833
+ read: {
834
+ storage: read?.storage === "session" ? "session" : "local",
835
+ key: typeof read?.key === "string" ? read.key : ""
836
+ },
837
+ set: {
838
+ storages: uniqueStorageKinds(set?.storages),
839
+ key: typeof set?.key === "string" ? set.key : "",
840
+ value: typeof set?.value === "string" ? set.value : ""
841
+ }
842
+ };
843
+ }
844
+ function isStorageReadConfigured(config) {
845
+ return Boolean(config.read?.key?.trim());
846
+ }
847
+ function isStorageSetConfigured(config) {
848
+ return Boolean(config.set?.key?.trim()) && (config.set?.storages?.length ?? 0) > 0;
849
+ }
850
+ function resolveStorageWriteValue(template, scope) {
851
+ const raw = template ?? "";
852
+ const trimmed = raw.trim();
853
+ if (!trimmed) return "";
854
+ if (isWholeScopeExpression(trimmed)) {
855
+ const value = evaluateScopeExpression(trimmed.slice(1, -1), scope);
856
+ return value === void 0 ? "" : value;
857
+ }
858
+ if (hasScopeTemplate(raw)) {
859
+ return evaluateScopeTemplate(raw, scope);
860
+ }
861
+ return raw;
862
+ }
863
+ function serializeStorageValue(value) {
864
+ if (value === void 0 || value === null) return "";
865
+ if (typeof value === "string") return value;
866
+ try {
867
+ return JSON.stringify(value);
868
+ } catch {
869
+ return String(value);
870
+ }
871
+ }
872
+ function deserializeStorageValue(raw) {
873
+ if (raw === null) return null;
874
+ const trimmed = raw.trim();
875
+ if (!trimmed) return raw;
876
+ if (!looksLikeJsonText(trimmed)) return raw;
877
+ try {
878
+ return JSON.parse(trimmed);
879
+ } catch {
880
+ return raw;
881
+ }
882
+ }
883
+ function getDefaultStorageAccessors() {
884
+ if (typeof window === "undefined") return null;
885
+ try {
886
+ return {
887
+ session: window.sessionStorage,
888
+ local: window.localStorage
889
+ };
890
+ } catch {
891
+ return null;
892
+ }
893
+ }
894
+ function requireStorage(accessors, kind) {
895
+ const target = kind === "session" ? accessors?.session : accessors?.local;
896
+ if (!target) {
897
+ throw new Error(
898
+ kind === "session" ? "\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301 sessionStorage" : "\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301 localStorage"
899
+ );
900
+ }
901
+ return target;
902
+ }
903
+ function executeStorageConfig(config, incomingScope, accessors) {
904
+ const normalized = normalizeStorageConfig(config);
905
+ const store = accessors === void 0 ? getDefaultStorageAccessors() : accessors;
906
+ if (isStorageSetConfigured(normalized)) {
907
+ const value = resolveStorageWriteValue(normalized.set.value, incomingScope);
908
+ const serialized = serializeStorageValue(value);
909
+ const key = normalized.set.key.trim();
910
+ for (const kind of normalized.set.storages) {
911
+ requireStorage(store, kind).setItem(key, serialized);
912
+ }
913
+ }
914
+ if (!isStorageReadConfigured(normalized)) {
915
+ return null;
916
+ }
917
+ return deserializeStorageValue(
918
+ requireStorage(store, normalized.read.storage).getItem(
919
+ normalized.read.key.trim()
920
+ )
921
+ );
922
+ }
923
+
813
924
  // src/logic-config.ts
814
925
  var DEFAULT_LOGIC_NODE_CONFIG = {
815
926
  sourceCode: `function update(input) {
@@ -1242,6 +1353,7 @@ var DEFAULT_LOGIC_NODE_TYPE = "Logic";
1242
1353
  var LIFECYCLE_NODE_TYPE = "Lifecycle";
1243
1354
  var FETCH_NODE_TYPE = "DataFetch";
1244
1355
  var JSON_NODE_TYPE = "JsonNode";
1356
+ var STORAGE_NODE_TYPE = "StorageNode";
1245
1357
  var CLOCK_NODE_TYPE = "Clock";
1246
1358
  var AND_NODE_TYPE = "AndLogic";
1247
1359
  var VIEW_NODE_TYPE = "ViewBind";
@@ -1276,6 +1388,12 @@ var jsonNodeDefinition = {
1276
1388
  outputs: [{ name: "out", kind: "data" }],
1277
1389
  behavior: { kind: "js", ref: "json-parse-run" }
1278
1390
  };
1391
+ var storageNodeDefinition = {
1392
+ type: STORAGE_NODE_TYPE,
1393
+ inputs: [{ name: "in", kind: "data" }],
1394
+ outputs: [{ name: "out", kind: "data" }],
1395
+ behavior: { kind: "js", ref: "storage-run" }
1396
+ };
1279
1397
  var clockNodeDefinition = {
1280
1398
  type: CLOCK_NODE_TYPE,
1281
1399
  inputs: [{ name: "in", kind: "data" }],
@@ -1309,6 +1427,7 @@ var nodeDefinitionRegistry = {
1309
1427
  [LIFECYCLE_NODE_TYPE]: lifecycleNodeDefinition,
1310
1428
  [FETCH_NODE_TYPE]: fetchNodeDefinition,
1311
1429
  [JSON_NODE_TYPE]: jsonNodeDefinition,
1430
+ [STORAGE_NODE_TYPE]: storageNodeDefinition,
1312
1431
  [CLOCK_NODE_TYPE]: clockNodeDefinition,
1313
1432
  [AND_NODE_TYPE]: andLogicNodeDefinition,
1314
1433
  [VIEW_NODE_TYPE]: viewBindNodeDefinition,
@@ -1495,6 +1614,7 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
1495
1614
  this.registerBlueprintRefBehavior();
1496
1615
  this.registerFetchBehavior();
1497
1616
  this.registerJsonBehavior();
1617
+ this.registerStorageBehavior();
1498
1618
  this.registerLogicBehavior();
1499
1619
  this.registerClockBehavior();
1500
1620
  this.registerAndBehavior();
@@ -2325,6 +2445,48 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
2325
2445
  io.emitFlow("out");
2326
2446
  });
2327
2447
  }
2448
+ registerStorageBehavior() {
2449
+ const runner = this;
2450
+ this.behaviors.registerJS("storage-run", async ({ token, io }) => {
2451
+ const node = runner.requireNode(token.nodeId);
2452
+ try {
2453
+ const inputPort = token.inPort || "in";
2454
+ const input = await io.getInput(inputPort);
2455
+ if (isFalseSignal(input)) {
2456
+ io.setOutput("out", input);
2457
+ io.emitFlow("out");
2458
+ return;
2459
+ }
2460
+ if (!isTrueSignal(input)) {
2461
+ io.setOutput(
2462
+ "out",
2463
+ createFalseSignal("\u5B58\u50A8\u8282\u70B9\u9700\u8981\u6536\u5230\u771F\u4FE1\u53F7\u540E\u624D\u4F1A\u8BFB\u5199\u7F13\u5B58")
2464
+ );
2465
+ io.emitFlow("out");
2466
+ return;
2467
+ }
2468
+ const incomingScope = runner.buildFetchIncomingScope(
2469
+ token.nodeId,
2470
+ inputPort,
2471
+ input
2472
+ );
2473
+ const config = normalizeStorageConfig({
2474
+ ...DEFAULT_STORAGE_NODE_CONFIG,
2475
+ ...node.storageConfig
2476
+ });
2477
+ const value = executeStorageConfig(config, incomingScope);
2478
+ io.setOutput("out", createTrueSignal(value));
2479
+ } catch (error) {
2480
+ io.setOutput(
2481
+ "out",
2482
+ createFalseSignal(
2483
+ error instanceof Error ? error.message : String(error)
2484
+ )
2485
+ );
2486
+ }
2487
+ io.emitFlow("out");
2488
+ });
2489
+ }
2328
2490
  registerClockBehavior() {
2329
2491
  const runner = this;
2330
2492
  this.behaviors.registerJS("clock-run", async ({ token, io }) => {
@@ -2580,6 +2742,6 @@ var BlueprintGraphRunner = class _BlueprintGraphRunner {
2580
2742
  }
2581
2743
  };
2582
2744
 
2583
- export { AND_NODE_TYPE, BLUEPRINT_ACTIVATION_INPUT_KEY, BLUEPRINT_CALL_STACK_KEY, BLUEPRINT_NODE_TYPE, BehaviorRegistry, BlueprintCycleError, BlueprintGraphRunner, CLOCK_NODE_TYPE, DEFAULT_CLOCK_NODE_CONFIG, DEFAULT_FETCH_REQUEST_CONFIG, DEFAULT_JSON_NODE_CONFIG, DEFAULT_LOGIC_NODE_CONFIG, DEFAULT_LOGIC_NODE_TYPE, DEFAULT_VIEW_EVENT_NODE_CONFIG, EVENT_NODE_TYPE, Executor, FETCH_CACHES, FETCH_CREDENTIALS, FETCH_HTTP_METHODS, FETCH_MODES, FETCH_NODE_TYPE, FETCH_REDIRECTS, FETCH_RESPONSE_TYPES, FETCH_SCOPE_AUTOCOMPLETE_FALLBACK, JSON_NODE_TYPE, LIFECYCLE_NODE_TYPE, LIFECYCLE_SIGNAL_KEY, PAGE_LIFECYCLE_LABELS, PAGE_LIFECYCLE_PHASES, UI_EVENT_PAYLOAD_KEY, VIEW_EVENT_SIGNAL_KEY, VIEW_EVENT_TYPES, VIEW_NODE_TYPE, abortClockNode, abortClockSession, andLogicNodeDefinition, applyFetchConfigScope, applyScopeAutocompleteSelection, assertNoBlueprintReferenceCycle, blueprintNodeDefinition, buildClockSessionKey, buildClockSignalValue, buildEndpointFullUrl, buildEndpointSuggestions, buildIncomingNodeScope, buildScopeExpression, clearClockSessionAbort, clockNodeDefinition, collectArmedViewEventBindings, collectArmedViewEventNodeIds, collectBlueprintLibraryRefs, collectIncomingNodeScopeEntries, collectViewEventBindings, combinePortSignalsOr, createClockOutputValue, createFalseSignal, createIncomingNodeScopeEntry, createLifecycleSignal, createTraceEntryId, createTrueSignal, createViewEventSignal, defaultLogicNodeDefinition, detectBlueprintReferenceCycle, detectRuntimeBlueprintCycle, draftFetchHeadersText, evaluateScopeExpression, evaluateScopeTemplate, evaluateScopeTemplateInJson, executeFetch, executeLogicConfig, fetchConfigHasScopeTemplate, fetchNodeDefinition, filterEndpointSuggestions, formatBlueprintCycleMessage, formatClockTime, getActiveClockNodeIds, getClockTickDelayOffsetMs, getClockTickWaitMs, getFetchBodyValidationError, getFetchHeadersValidationError, getNodeDefinition, getScopeAutocompleteSuggestions, hasScopeTemplate, isClockNodeActive, isClockScheduleActive, isClockSessionAborted, isFalseSignal, isTrueSignal, isViewEventType, isWholeScopeExpression, jsonNodeDefinition, latestTraceOutputsByNode, lifecycleNodeDefinition, looksLikeJsonText, nodeDefinitionRegistry, normalizeClockConfig, normalizeFetchRequestConfig, normalizeViewEventConfig, parseFetchHeadersJson, parseJsonConfig, parseJsonText, parseScopeAutocomplete, parseSwaggerDocument, registerDefaultBehaviors, resolveBlueprintCallStack, resolveFetchBody, resolveFetchHeaders, resolveFetchIncomingScope, resolveFetchRequestUrl, resolveFetchScopeAutocompleteRoot, scheduleClockOutputs, serializeTraceValue, snapshotDomEvent, snapshotViewEventNode, startClockSchedule, stopAllClockSchedules, stopClockSchedule, stringifyScopeValue, subscribeActiveClockNodes, validateClockScheduleConfig, validateFetchJsonText, validateJsonString, validateLogicSourceCode, viewBindNodeDefinition, viewEventNodeDefinition };
2745
+ export { AND_NODE_TYPE, BLUEPRINT_ACTIVATION_INPUT_KEY, BLUEPRINT_CALL_STACK_KEY, BLUEPRINT_NODE_TYPE, BehaviorRegistry, BlueprintCycleError, BlueprintGraphRunner, CLOCK_NODE_TYPE, DEFAULT_CLOCK_NODE_CONFIG, DEFAULT_FETCH_REQUEST_CONFIG, DEFAULT_JSON_NODE_CONFIG, DEFAULT_LOGIC_NODE_CONFIG, DEFAULT_LOGIC_NODE_TYPE, DEFAULT_STORAGE_NODE_CONFIG, DEFAULT_VIEW_EVENT_NODE_CONFIG, EVENT_NODE_TYPE, Executor, FETCH_CACHES, FETCH_CREDENTIALS, FETCH_HTTP_METHODS, FETCH_MODES, FETCH_NODE_TYPE, FETCH_REDIRECTS, FETCH_RESPONSE_TYPES, FETCH_SCOPE_AUTOCOMPLETE_FALLBACK, JSON_NODE_TYPE, LIFECYCLE_NODE_TYPE, LIFECYCLE_SIGNAL_KEY, PAGE_LIFECYCLE_LABELS, PAGE_LIFECYCLE_PHASES, STORAGE_KINDS, STORAGE_NODE_TYPE, UI_EVENT_PAYLOAD_KEY, VIEW_EVENT_SIGNAL_KEY, VIEW_EVENT_TYPES, VIEW_NODE_TYPE, abortClockNode, abortClockSession, andLogicNodeDefinition, applyFetchConfigScope, applyScopeAutocompleteSelection, assertNoBlueprintReferenceCycle, blueprintNodeDefinition, buildClockSessionKey, buildClockSignalValue, buildEndpointFullUrl, buildEndpointSuggestions, buildIncomingNodeScope, buildScopeExpression, clearClockSessionAbort, clockNodeDefinition, collectArmedViewEventBindings, collectArmedViewEventNodeIds, collectBlueprintLibraryRefs, collectIncomingNodeScopeEntries, collectViewEventBindings, combinePortSignalsOr, createClockOutputValue, createFalseSignal, createIncomingNodeScopeEntry, createLifecycleSignal, createTraceEntryId, createTrueSignal, createViewEventSignal, defaultLogicNodeDefinition, deserializeStorageValue, detectBlueprintReferenceCycle, detectRuntimeBlueprintCycle, draftFetchHeadersText, evaluateScopeExpression, evaluateScopeTemplate, evaluateScopeTemplateInJson, executeFetch, executeLogicConfig, executeStorageConfig, fetchConfigHasScopeTemplate, fetchNodeDefinition, filterEndpointSuggestions, formatBlueprintCycleMessage, formatClockTime, getActiveClockNodeIds, getClockTickDelayOffsetMs, getClockTickWaitMs, getFetchBodyValidationError, getFetchHeadersValidationError, getNodeDefinition, getScopeAutocompleteSuggestions, hasScopeTemplate, isClockNodeActive, isClockScheduleActive, isClockSessionAborted, isFalseSignal, isStorageReadConfigured, isStorageSetConfigured, isTrueSignal, isViewEventType, isWholeScopeExpression, jsonNodeDefinition, latestTraceOutputsByNode, lifecycleNodeDefinition, looksLikeJsonText, nodeDefinitionRegistry, normalizeClockConfig, normalizeFetchRequestConfig, normalizeStorageConfig, normalizeViewEventConfig, parseFetchHeadersJson, parseJsonConfig, parseJsonText, parseScopeAutocomplete, parseSwaggerDocument, registerDefaultBehaviors, resolveBlueprintCallStack, resolveFetchBody, resolveFetchHeaders, resolveFetchIncomingScope, resolveFetchRequestUrl, resolveFetchScopeAutocompleteRoot, resolveStorageWriteValue, scheduleClockOutputs, serializeStorageValue, serializeTraceValue, snapshotDomEvent, snapshotViewEventNode, startClockSchedule, stopAllClockSchedules, stopClockSchedule, storageNodeDefinition, stringifyScopeValue, subscribeActiveClockNodes, uniqueStorageKinds, validateClockScheduleConfig, validateFetchJsonText, validateJsonString, validateLogicSourceCode, viewBindNodeDefinition, viewEventNodeDefinition };
2584
2746
  //# sourceMappingURL=index.js.map
2585
2747
  //# sourceMappingURL=index.js.map