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,11 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
const { defineFlatConfig } = require('@flowgram.ai/eslint-config');
module.exports = defineFlatConfig({
preset: 'web',
packageRoot: __dirname,
});
@@ -0,0 +1,49 @@
{
"name": "@flowgram.ai/variable-plugin",
"version": "0.1.8",
"homepage": "https://flowgram.ai/",
"repository": "https://github.com/bytedance/flowgram.ai",
"license": "MIT",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/index.js"
},
"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "npm run build:fast -- --dts-resolve",
"build:fast": "tsup src/index.ts --format cjs,esm --sourcemap --legacy-output",
"build:watch": "npm run build:fast -- --dts-resolve",
"clean": "rimraf dist",
"test": "exit 0",
"test:cov": "exit 0",
"ts-check": "tsc --noEmit",
"watch": "npm run build:fast -- --dts-resolve --watch --ignore-watch dist"
},
"dependencies": {
"@flowgram.ai/core": "workspace:*",
"@flowgram.ai/document": "workspace:*",
"@flowgram.ai/variable-core": "workspace:*",
"@flowgram.ai/variable-layout": "workspace:*",
"inversify": "^6.0.1",
"reflect-metadata": "~0.2.2"
},
"devDependencies": {
"@flowgram.ai/eslint-config": "workspace:*",
"@flowgram.ai/ts-config": "workspace:*",
"@vitest/coverage-v8": "^3.2.4",
"eslint": "^9.0.0",
"tsup": "^8.0.1",
"typescript": "^5.8.3",
"vitest": "^3.2.4"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
@@ -0,0 +1,101 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import {
FlowNodeVariableData,
FreeLayoutScopeChain,
FixedLayoutScopeChain,
VariableChainConfig,
bindGlobalScope,
ScopeChainTransformService,
} from '@flowgram.ai/variable-layout';
import {
VariableContainerModule,
ASTNodeRegistry,
ASTRegisters,
VariableEngine,
ScopeChain,
} from '@flowgram.ai/variable-core';
import { FlowDocument } from '@flowgram.ai/document';
import { PluginContext, definePluginCreator } from '@flowgram.ai/core';
import { EntityManager } from '@flowgram.ai/core';
/**
* @deprecated 请使用 @injectToAst(XXXService) declare xxxService: XXXService 实现外部依赖注入
*/
type Injector = (ctx: PluginContext) => Record<string, any>;
export interface VariablePluginOptions {
enable?: boolean;
/**
* Custom Extends ASTNode
*/
extendASTNodes?: (ASTNodeRegistry | [ASTNodeRegistry] | [ASTNodeRegistry, Injector])[];
/**
* Layout method
*/
layout?: 'fixed' | 'free';
/**
* @deprecated use chainConfig instead
*/
layoutConfig?: VariableChainConfig;
/**
* Configuration for scope chain
*/
chainConfig?: VariableChainConfig;
}
export const createVariablePlugin = definePluginCreator<VariablePluginOptions>({
onBind({ bind }, opts) {
const { layout, layoutConfig, chainConfig } = opts;
bind(ScopeChainTransformService).toSelf().inSingletonScope();
if (layout === 'free') {
bind(ScopeChain).to(FreeLayoutScopeChain).inSingletonScope();
}
if (layout === 'fixed') {
bind(ScopeChain).to(FixedLayoutScopeChain).inSingletonScope();
}
if (chainConfig) {
bind(VariableChainConfig).toConstantValue(chainConfig || {});
} else if (layoutConfig) {
console.warn(`Layout Config deprecated, use chainConfig instead`);
bind(VariableChainConfig).toConstantValue(layoutConfig || {});
}
bindGlobalScope(bind);
},
onInit(ctx, opts) {
const { extendASTNodes } = opts || {};
const variableEngine = ctx.get<VariableEngine>(VariableEngine);
const astRegisters = ctx.get<ASTRegisters>(ASTRegisters);
const entityManager = ctx.get<EntityManager>(EntityManager);
const document = ctx.get<FlowDocument>(FlowDocument);
/**
* 注册扩展 AST 节点
*/
(extendASTNodes || []).forEach((info) => {
if (Array.isArray(info)) {
const [extendASTNode, injector] = info;
astRegisters.registerAST(extendASTNode, injector ? () => injector(ctx) : undefined);
return;
}
astRegisters.registerAST(info);
});
/**
* 扩展 FlowNodeVariableData
*/
entityManager.registerEntityData(FlowNodeVariableData, () => ({ variableEngine } as any));
document.registerNodeDatas(FlowNodeVariableData);
},
containerModules: [VariableContainerModule],
});
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
export * from './create-variable-plugin';
export * from '@flowgram.ai/variable-core';
export {
FlowNodeVariableData,
GlobalScope,
ScopeChainTransformService,
getNodeScope,
getNodePrivateScope,
FlowNodeScopeType,
type FlowNodeScopeMeta,
type FlowNodeScope,
} from '@flowgram.ai/variable-layout';
@@ -0,0 +1,7 @@
{
"extends": "@flowgram.ai/ts-config/tsconfig.flow.path.json",
"compilerOptions": {
},
"include": ["./src"],
"exclude": ["node_modules"]
}
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
const path = require('path');
import { defineConfig } from 'vitest/config';
export default defineConfig({
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
},
test: {
globals: true,
mockReset: false,
environment: 'jsdom',
setupFiles: [path.resolve(__dirname, './vitest.setup.ts')],
include: ['**/?(*.){test,spec}.?(c|m)[jt]s?(x)'],
exclude: [
'**/__mocks__**',
'**/node_modules/**',
'**/dist/**',
'**/lib/**', // lib 编译结果忽略掉
'**/cypress/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
],
},
});
@@ -0,0 +1,6 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import 'reflect-metadata';