mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
refactor: rename queueFactory => queueBuilder, exitCondition=>exitBranch
This commit is contained in:
parent
b4b3330bfb
commit
44aba7aa3f
@ -1,7 +1,7 @@
|
||||
import { types as t } from "@marko/compiler";
|
||||
import { Tag, assertNoParams, assertNoVar } from "@marko/babel-utils";
|
||||
import { exitCondition, queueBranchFactory } from "./if";
|
||||
import { setQueueFactory } from "../../util/apply-hydrate";
|
||||
import { exitBranch, queueBranchBuilder } from "./if";
|
||||
import { setQueueBuilder } from "../../util/apply-hydrate";
|
||||
|
||||
export default {
|
||||
translate: {
|
||||
@ -36,10 +36,10 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
setQueueFactory(tag, queueBranchFactory);
|
||||
setQueueBuilder(tag, queueBranchBuilder);
|
||||
},
|
||||
exit(tag) {
|
||||
exitCondition(tag);
|
||||
exitBranch(tag);
|
||||
},
|
||||
},
|
||||
attributes: {},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { types as t } from "@marko/compiler";
|
||||
import { Tag, assertNoParams, assertNoVar } from "@marko/babel-utils";
|
||||
import { setQueueFactory } from "../../util/apply-hydrate";
|
||||
import { exitCondition, queueBranchFactory } from "./if";
|
||||
import { setQueueBuilder } from "../../util/apply-hydrate";
|
||||
import { exitBranch, queueBranchBuilder } from "./if";
|
||||
|
||||
export default {
|
||||
translate: {
|
||||
@ -31,10 +31,10 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
setQueueFactory(tag, queueBranchFactory);
|
||||
setQueueBuilder(tag, queueBranchBuilder);
|
||||
},
|
||||
exit(tag) {
|
||||
exitCondition(tag);
|
||||
exitBranch(tag);
|
||||
},
|
||||
},
|
||||
attributes: {},
|
||||
|
||||
@ -5,8 +5,8 @@ import * as walks from "../../util/walks";
|
||||
import * as sorted from "../../util/sorted-arr";
|
||||
import {
|
||||
addStatement,
|
||||
queueFactory,
|
||||
setQueueFactory,
|
||||
queueBuilder,
|
||||
setQueueBuilder,
|
||||
} from "../../util/apply-hydrate";
|
||||
import { callRuntime } from "../../util/runtime";
|
||||
import { isCoreTagName } from "../../util/is-core-tag";
|
||||
@ -72,13 +72,13 @@ export default {
|
||||
|
||||
walks.visit(tag, walks.WalkCodes.Replace);
|
||||
walks.enterShallow(tag);
|
||||
setQueueFactory(tag, queueBranchFactory);
|
||||
setQueueBuilder(tag, queueBranchBuilder);
|
||||
if (isOutputHTML()) {
|
||||
writer.flushBefore(tag);
|
||||
}
|
||||
},
|
||||
exit(tag) {
|
||||
exitCondition(tag);
|
||||
exitBranch(tag);
|
||||
},
|
||||
},
|
||||
attributes: {},
|
||||
@ -99,7 +99,7 @@ const BRANCHES_LOOKUP = new WeakMap<
|
||||
}[]
|
||||
>();
|
||||
|
||||
export const queueBranchFactory: queueFactory = (
|
||||
export const queueBranchBuilder: queueBuilder = (
|
||||
binding,
|
||||
functionIdentifier,
|
||||
targetSectionId
|
||||
@ -114,7 +114,7 @@ export const queueBranchFactory: queueFactory = (
|
||||
);
|
||||
};
|
||||
|
||||
export function exitCondition(tag: t.NodePath<t.MarkoTag>) {
|
||||
export function exitBranch(tag: t.NodePath<t.MarkoTag>) {
|
||||
const bodySectionId = getSectionId(tag.get("body"));
|
||||
const nextTag = tag.getNextSibling();
|
||||
const isLast = !(
|
||||
|
||||
@ -6,8 +6,8 @@ import * as walks from "../util/walks";
|
||||
import {
|
||||
addStatement,
|
||||
bindingToApplyId,
|
||||
queueFactory,
|
||||
setQueueFactory,
|
||||
queueBuilder,
|
||||
setQueueBuilder,
|
||||
} from "../util/apply-hydrate";
|
||||
import { getOrCreateSectionId, getSectionId } from "../util/sections";
|
||||
import { ReserveType, reserveScope } from "../util/reserve";
|
||||
@ -45,7 +45,7 @@ export default {
|
||||
|
||||
walks.visit(tag, walks.WalkCodes.Replace);
|
||||
walks.enterShallow(tag);
|
||||
setQueueFactory(tag, queueLoopFactory);
|
||||
setQueueBuilder(tag, queueEachBuilder);
|
||||
if (isOutputHTML()) {
|
||||
writer.flushBefore(tag);
|
||||
}
|
||||
@ -175,7 +175,7 @@ const translateDOM = {
|
||||
},
|
||||
};
|
||||
|
||||
const queueLoopFactory: queueFactory = (
|
||||
const queueEachBuilder: queueBuilder = (
|
||||
binding,
|
||||
functionIdentifier,
|
||||
targetSectionId
|
||||
|
||||
@ -16,7 +16,7 @@ interface ReferenceGroup {
|
||||
statements: t.Statement[];
|
||||
}
|
||||
|
||||
export type queueFactory = (
|
||||
export type queueBuilder = (
|
||||
binding: Reserve,
|
||||
functionIdentifier: t.Identifier,
|
||||
targetSectionId: number
|
||||
@ -24,11 +24,14 @@ export type queueFactory = (
|
||||
|
||||
const [getApply] = createSectionState<ReferenceGroup[]>("apply", () => []);
|
||||
const [getHydrate] = createSectionState<ReferenceGroup[]>("hydrate", () => []);
|
||||
const [getQueueFactory, _setQueueFactory] =
|
||||
createSectionState<queueFactory>("queue");
|
||||
const [getQueueBuilder, _setQueueBuilder] =
|
||||
createSectionState<queueBuilder>("queue");
|
||||
|
||||
export function setQueueFactory(tag: t.NodePath<t.MarkoTag>, fn: queueFactory) {
|
||||
_setQueueFactory(getSectionId(tag.get("body")), fn);
|
||||
export function setQueueBuilder(
|
||||
tag: t.NodePath<t.MarkoTag>,
|
||||
builder: queueBuilder
|
||||
) {
|
||||
_setQueueBuilder(getSectionId(tag.get("body")), builder);
|
||||
}
|
||||
|
||||
export function addStatement(
|
||||
@ -123,7 +126,7 @@ export function writeApplyGroups(sectionId: number) {
|
||||
];
|
||||
body = t.blockStatement(statements);
|
||||
|
||||
const factory = getQueueFactory(sectionId);
|
||||
const factory = getQueueBuilder(sectionId);
|
||||
if (factory) {
|
||||
i += addStatement(
|
||||
"apply",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user