chore: import upstream snapshot with attribution
CI / build (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:09:51 +08:00
commit 0232b4e2bb
3528 changed files with 291404 additions and 0 deletions
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { Container, ContainerModule, interfaces } from 'inversify';
import { ScopeChain, VariableContainerModule } from '../src';
import { MockScopeChain } from './mock-chain';
import { createPlaygroundContainer } from '@flowgram.ai/core';
export function getContainer(customModule?: interfaces.ContainerModuleCallBack): Container {
const container = createPlaygroundContainer() as Container;
container.load(VariableContainerModule);
container.bind(ScopeChain).to(MockScopeChain).inSingletonScope();
if(customModule) {
container.load(new ContainerModule(customModule))
}
return container;
}
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { ScopeChain, Scope } from '../src';
/**
* 规则:
* - Global 覆盖所有 Scope,所有 Scope 依赖 Global
* - 存在环路:cycle1 -> cycle2 -> cycle3 -> cycle1
*/
export class MockScopeChain extends ScopeChain {
getDeps(scope: Scope): Scope[] {
const res: Scope[] = [];
if (scope.id === 'global') {
return [];
}
const global = this.variableEngine.getScopeById('global');
if (global) {
res.push(global);
}
// 模拟循环依赖场景
if (String(scope.id).startsWith('cycle')) {
return this.variableEngine
.getAllScopes()
.filter((_scope) => String(_scope.id).startsWith('cycle') && _scope.id !== scope.id);
}
return res;
}
getCovers(scope: Scope): Scope[] {
if (scope.id === 'global') {
return this.variableEngine.getAllScopes().filter(_scope => _scope.id !== 'global');
}
// 模拟循环依赖场景
if (String(scope.id).startsWith('cycle')) {
return this.variableEngine
.getAllScopes()
.filter((_scope) => String(_scope.id).startsWith('cycle') && _scope.id !== scope.id);
}
return [];
}
sortAll(): Scope[] {
return this.variableEngine.getAllScopes();
}
}
@@ -0,0 +1,85 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { ASTKind, ObjectJSON, VariableDeclarationListJSON } from '../src';
export const simpleVariableList = {
kind: ASTKind.VariableDeclarationList,
declarations: [
{
type: ASTKind.String,
key: 'string',
},
{
type: ASTKind.Boolean,
key: 'boolean',
},
{
// VariableDeclarationList 的 declarations 中可以不用声明 Kind
// kind: ASTKind.VariableDeclaration,
type: ASTKind.Number,
key: 'number',
},
{
kind: ASTKind.VariableDeclaration,
type: ASTKind.Integer,
key: 'integer',
},
{
kind: ASTKind.VariableDeclaration,
type: {
kind: ASTKind.Object,
properties: [
{
key: 'key1',
type: ASTKind.String,
// Object 的 properties 中可以不用声明 Kind
kind: ASTKind.Property,
},
{
key: 'key2',
type: {
kind: ASTKind.Object,
properties: [
{
key: 'key1',
type: ASTKind.Number,
},
],
} as ObjectJSON,
},
{
key: 'key3',
type: {
kind: ASTKind.Array,
itemType: ASTKind.String,
},
},
{
key: 'key4',
type: {
kind: ASTKind.Array,
items: {
kind: ASTKind.Object,
properties: [
{
key: 'key1',
type: ASTKind.Boolean,
},
],
} as ObjectJSON,
},
},
],
} as ObjectJSON,
key: 'object',
},
{
kind: ASTKind.VariableDeclaration,
type: { kind: ASTKind.Map, valueType: ASTKind.Number },
key: 'map',
},
],
} as VariableDeclarationListJSON;