Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = [
},
{
path: "packages/brick-utils/dist/index.esm.js",
limit: "136 KB",
limit: "138 KB",
},
{
path: "packages/editor-bricks-helper/dist/index.esm.js",
Expand Down
3 changes: 3 additions & 0 deletions dll/editor-bricks-helper/manifest.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"asyncProcessBrick",
"asyncProcessStoryboard",
"collectBricksByCustomTemplates",
"computeConstantCondition",
"computeRealRoutePath",
"convertValueByPrecision",
"cook",
Expand Down Expand Up @@ -54,6 +55,8 @@
"precookFunction",
"preevaluate",
"prefetchScript",
"removeDeadConditions",
"removeDeadConditionsInTpl",
"resolveContextConcurrently",
"restoreDynamicTemplates",
"scanAppGetMenuInAny",
Expand Down
2 changes: 2 additions & 0 deletions etc/brick-types.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,8 @@ export interface RuntimeMisc {
//
// @internal (undocumented)
export interface RuntimeStoryboard extends Storyboard {
// (undocumented)
$$deadConditionsRemoved?: boolean;
// (undocumented)
$$depsProcessed?: boolean;
// (undocumented)
Expand Down
3 changes: 3 additions & 0 deletions packages/brick-dll/manifest.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,7 @@
"asyncProcessBrick",
"asyncProcessStoryboard",
"collectBricksByCustomTemplates",
"computeConstantCondition",
"computeRealRoutePath",
"convertValueByPrecision",
"cook",
Expand Down Expand Up @@ -3539,6 +3540,8 @@
"precookFunction",
"preevaluate",
"prefetchScript",
"removeDeadConditions",
"removeDeadConditionsInTpl",
"resolveContextConcurrently",
"restoreDynamicTemplates",
"scanAppGetMenuInAny",
Expand Down
2 changes: 1 addition & 1 deletion packages/brick-kit/src/checkIf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface IfContainer {
*
* ```yaml
* - brick: your.any-brick
* if: '<% FLAGS['your-feature-flag'] %>'
* if: '<% FLAGS["your-feature-flag"] %>'
* ```
*/
if?: unknown;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { CustomTemplateConstructor } from "@next-core/brick-types";
import { removeDeadConditionsInTpl } from "@next-core/brick-utils";
import { getRuntime } from "../../runtime";
import { appRegistered, customTemplateRegistry } from "./constants";

export function registerCustomTemplate(
tplName: string,
tplConstructor: CustomTemplateConstructor,
appId?: string
appId?: string,
deadCOnditionsRemoved?: boolean
): void {
let tagName = tplName;
// When a template is registered by an app, its namespace maybe missed.
Expand All @@ -29,6 +32,12 @@ export function registerCustomTemplate(
);
}
}
if (!deadCOnditionsRemoved && process.env.NODE_ENV !== "test") {
removeDeadConditionsInTpl(tplConstructor, {
constantFeatureFlags: true,
featureFlags: getRuntime().getFeatureFlags(),
});
}
// Now we allow re-register custom template
customTemplateRegistry.set(tagName, {
...tplConstructor,
Expand Down
3 changes: 2 additions & 1 deletion packages/brick-kit/src/core/Kernel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ describe("Kernel", () => {
proxy: {},
bricks: [],
},
"app-a"
"app-a",
true
);

spyOnLoadScript.mockClear();
Expand Down
3 changes: 2 additions & 1 deletion packages/brick-kit/src/core/Kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ export class Kernel {
proxy: tpl.proxy,
state: tpl.state,
},
storyboard.app?.id
storyboard.app?.id,
true
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/brick-kit/src/core/Router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ jest.mock("../auth");
jest.mock("../themeAndMode");
jest.mock("../runtime");
jest.mock("../internal/checkPermissions");
jest.mock("../internal/getStandaloneInstalledApps");
jest.mock("../internal/getStandaloneInstalledApps", () => ({
getStandaloneInstalledApps: jest.fn().mockReturnValue([]),
preFetchStandaloneInstalledApps: jest.fn().mockResolvedValue(undefined),
}));
jest.mock("@next-core/easyops-analytics", () => ({
apiAnalyzer: {
create: () => jest.mock,
Expand Down
24 changes: 19 additions & 5 deletions packages/brick-kit/src/core/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
scanStoryboard,
mapCustomApisToNameAndNamespace,
CustomApiInfo,
removeDeadConditions,
} from "@next-core/brick-utils";
import { HttpResponseError } from "@next-core/brick-http";
import { apiAnalyzer, userAnalytics } from "@next-core/easyops-analytics";
import {
LocationContext,
Expand Down Expand Up @@ -48,7 +50,6 @@ import { preCheckPermissions } from "../internal/checkPermissions";
import { clearPollTimeout } from "../internal/poll";
import { shouldBeDefaultCollapsed } from "../internal/shouldBeDefaultCollapsed";
import { registerStoryboardFunctions } from "./StoryboardFunctions";
import { HttpResponseError } from "@next-core/brick-http";
import { registerMock } from "./MockRegistry";
import { registerFormRenderer } from "./CustomForms/registerFormRenderer";
import {
Expand Down Expand Up @@ -252,22 +253,35 @@ export class Router {
if (storyboard) {
await this.kernel.fulfilStoryboard(storyboard);

removeDeadConditions(storyboard, {
constantFeatureFlags: true,
featureFlags: this.featureFlags,
});

// 将动态解析后的模板还原,以便重新动态解析。
restoreDynamicTemplates(storyboard);

const parallelRequests: Promise<unknown>[] = [];

// 预加载权限信息
if (isLoggedIn() && !getAuth().isAdmin) {
await preCheckPermissions(storyboard);
parallelRequests.push(preCheckPermissions(storyboard));
}

// Standalone App 需要额外读取 Installed App 信息
if (window.STANDALONE_MICRO_APPS && !window.NO_AUTH_GUARD) {
// TODO: get standalone apps when NO_AUTH_GUARD, maybe from conf.yaml
await preFetchStandaloneInstalledApps(storyboard);
this.kernel.bootstrapData.offSiteStandaloneApps =
getStandaloneInstalledApps();
parallelRequests.push(
preFetchStandaloneInstalledApps(storyboard).then(() => {
this.kernel.bootstrapData.offSiteStandaloneApps =
getStandaloneInstalledApps();
})
);
}

// `loadDepsOfStoryboard()` may requires these data.
await Promise.all(parallelRequests);

// 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
const subStoryboard =
this.locationContext.getSubStoryboardByRoute(storyboard);
Expand Down
1 change: 1 addition & 0 deletions packages/brick-types/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export interface RuntimeStoryboard extends Storyboard {
$$fulfilled?: boolean;
$$fulfilling?: Promise<void>;
$$i18nFulfilled?: boolean;
$$deadConditionsRemoved?: boolean;
}

export function isRouteConfOfBricks(
Expand Down
1 change: 1 addition & 0 deletions packages/brick-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ export * from "./visitStoryboard";
export * from "./debounceByAnimationFrame";
export * from "./scanInstalledAppsInStoryboard";
export * from "./makeThrottledAggregation";
export * from "./removeDeadConditions";
Loading