xstate-tsserver
Version:
XState tsserver plugin for easier navigation in state machines
295 lines (288 loc) • 7.72 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initialStateQuery = exports.transitionQuery = exports.stateQuery = exports.setupImplementableQuery = exports.machineDelaysQuery = exports.setupDelaysQuery = exports.machineActorsQuery = exports.setupActorsQuery = exports.machineGuardsQuery = exports.setupGuardsQuery = exports.machineActionsQuery = exports.setupActionsQuery = exports.machineWithSetupQuery = void 0;
exports.machineWithSetupQuery = `
(call_expression
function: (member_expression
object: (call_expression
function: (identifier) .setup (#eq? .setup "setup")
arguments: (arguments) .setup.config)
property: (property_identifier) .createMachine (#eq? .createMachine "createMachine"))
arguments: (arguments
(object) .state.config .root.config)) .machine
`;
exports.setupActionsQuery = `
(pair
key: (property_identifier) (#eq? "actions")
value: (object [
(pair
key: (property_identifier) .name
value: (_)
)
(shorthand_property_identifier) .name
])
)
`;
exports.machineActionsQuery = `
(pair
key: (property_identifier)
(#match? "actions|entry|exit")
value: [
(array (string (string_fragment) .action.name) .action)
(string (string_fragment) .action.name) .action
(array
(object
(pair
key: (property_identifier)
(#eq? "type")
value: (string (string_fragment) .action.name) .action
)
)
)
(object
(pair
key: (property_identifier)
(#eq? "type")
value: (string (string_fragment) .action.name) .action
)
)
]
)
(call_expression
function: (identifier) (#eq? "enqueue")
arguments: (arguments [
(string (string_fragment) .action.name) .action
(object
(pair
key: (property_identifier)
(#eq? "type")
value: (string (string_fragment) .action.name) .action
)
)
])
)
`;
exports.setupGuardsQuery = `
(pair
key: (property_identifier) (#eq? "guards")
value: (object [
(pair
key: (property_identifier) .name
value: (_)
)
(shorthand_property_identifier) .name
])
)
`;
exports.machineGuardsQuery = `
(pair
key: (property_identifier)
(#eq? "guard")
value: [
(string (string_fragment) .guard.name) .guard
(object
(pair
key: (property_identifier)
(#eq? "type")
value: (string (string_fragment) .guard.name) .guard
)
)
]
)
(call_expression
function: (identifier) (#match? "check|not")
arguments: (arguments [
(string (string_fragment) .guard.name) .guard
(object
(pair
key: (property_identifier)
(#eq? "type")
value: (string (string_fragment) .guard.name) .guard
)
)]
)
)
(call_expression
function: (identifier) (#match? "and|or")
arguments: (arguments
(array [
(string (string_fragment) .guard.name) .guard
(object
(pair
key: (property_identifier)
(#eq? "type")
value: (string (string_fragment) .guard.name) .guard
)
)]
)
)
)
`;
exports.setupActorsQuery = `
(pair
key: (property_identifier) (#eq? "actors")
value: (object [
(pair
key: (property_identifier) .name
value: (_)
)
(shorthand_property_identifier) .name
])
)
`;
exports.machineActorsQuery = `
(pair
key: (property_identifier) (#eq? "invoke")
value: [
(object
(pair
key: (property_identifier) .src (#eq? .src "src")
value: (string (string_fragment) .actor.name) .actor
)
)
(array
(object
(pair
key: (property_identifier) .src (#eq? .src "src")
value: (string (string_fragment) .actor.name) .actor
)
)
)
]
)
(pair
key: (property_identifier)
(#match? "actions|entry|exit")
value: [
(call_expression
function: (identifier) .spawnChild (#eq? .spawnChild "spawnChild")
arguments: (arguments (string (string_fragment) .actor.name) .actor)
)
(array
(call_expression
function: (identifier) .spawnChild (#eq? .spawnChild "spawnChild")
arguments: (arguments (string (string_fragment) .actor.name) .actor)
)
)
]
)
(call_expression
function: (identifier) .spawn (#eq? .spawn "spawn")
arguments: (arguments
(string (string_fragment) .actor.name) .actor
)
)
`;
exports.setupDelaysQuery = `
(pair
key: (property_identifier) (#eq? "delays")
value: (object [
(pair
key: (property_identifier) .name
value: (_)
)
(shorthand_property_identifier) .name
])
)
`;
exports.machineDelaysQuery = `
(pair
key: (property_identifier) (#eq? "after")
value: (object
(pair
key: (property_identifier) .delay .delay.name
value: (_)
)
)
)
(call_expression
function: (identifier) (#match? "sendTo|raise")
arguments: (arguments
(object
(pair
key: (property_identifier) (#eq? "delay")
value: (string (string_fragment) .delay.name) .delay
)
)
)
)
`;
exports.setupImplementableQuery = `
(pair
key: (property_identifier) .key (#match? .key "actors|actions|guards|delays")
value: (object [
(pair
key: (property_identifier) .name
value: (_) .definition
)
(shorthand_property_identifier) .name .definition
])
)
`;
exports.stateQuery = `
(object
(pair
key: (property_identifier) .key (#eq? .key "states")
value: (object
(pair
key: (property_identifier) .state.name
value: (object) .state.config
) .state
)
)
)
`;
exports.transitionQuery = `
(pair
key: (property_identifier) .key (#match? .key "after|on$")
value: (object
(pair
key: (_)
value: [
(string) .target
(object
(pair
key: (property_identifier) .target.key
value: (string) .target
)
)
(array
(object
(pair
key: (property_identifier) .target.key (#eq? .target.key "target")
value: (string) .target
)
)
)
]
)
)
)
(pair
key: (property_identifier) .key (#match? .key "onDone|onError|always")
value: [
(string) .target
(object
(pair
key: (property_identifier) .target.key
value: (string) .target
)
)
(array
(object
(pair
key: (property_identifier) .target.key (#eq? .target.key "target")
value: (string) .target
)
)
)
]
)
`;
exports.initialStateQuery = `
(pair
key: (property_identifier) (#eq? "initial")
value: (string) .state
)
`;
//# sourceMappingURL=queries.js.map