@volter/editor-react 0.5.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/NOTICE +4 -0
- package/contributions/component-contracts.service.ts +18 -0
- package/dist-node/component-prop-worker.mjs +335 -0
- package/dist-node/serving.mjs +5842 -0
- package/package.json +51 -0
- package/serving/component-prop-worker.ts +72 -0
- package/serving/index.ts +21 -0
- package/serving/ui-oid-plugin.ts +1844 -0
- package/src/source/component-prop-types.ts +517 -0
- package/src/source/ensure-import.ts +132 -0
- package/src/source/oid-transform.ts +1667 -0
- package/src/source/plan-csf-story.ts +196 -0
- package/src/source/plan-extract-component.ts +421 -0
- package/src/source/plan-fork-component.ts +621 -0
- package/src/source/plan-named-style.ts +95 -0
- package/src/source/plan-source-edit.ts +353 -0
- package/src/source/r3f-contract-resolver.ts +327 -0
- package/src/source/r3f-diagnostic-index.ts +165 -0
- package/src/source/r3f-environment-binding.ts +106 -0
- package/src/source/r3f-joint-binding.ts +228 -0
- package/src/source/r3f-lod-binding.ts +81 -0
- package/src/source/r3f-particle-binding.ts +213 -0
- package/src/source/r3f-physics-binding.ts +454 -0
- package/src/source/r3f-project-contracts.ts +444 -0
- package/src/source/relative-import-specifier.ts +34 -0
- package/src/source/reparent-guard.ts +531 -0
- package/src/source/source-edit-request.ts +22 -0
- package/src/source/syntactic-prop-specs.ts +296 -0
- package/src/source/ts-ast.ts +171 -0
- package/src/source/utility-class-support.ts +169 -0
- package/src/source/write-component-default.ts +133 -0
- package/src/source/writer.ts +1982 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volter/editor-react",
|
|
3
|
+
"author": "Volter AI, Inc.",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"version": "0.5.66",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"description": "React source authoring for Volter Editor: JSX identity, source writes, component contracts and declared props.",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/volter-ai/editor.git",
|
|
14
|
+
"directory": "packages/editor-react"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"contributions",
|
|
19
|
+
"serving",
|
|
20
|
+
"dist-node",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"NOTICE"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
"./source/*": "./src/source/*.ts",
|
|
26
|
+
"./contributions/*": "./contributions/*",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "node scripts/build-serving.mjs",
|
|
31
|
+
"prepack": "npm run build",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.json"
|
|
33
|
+
},
|
|
34
|
+
"vgai": {
|
|
35
|
+
"contributions": [
|
|
36
|
+
"./contributions/component-contracts.service.ts"
|
|
37
|
+
],
|
|
38
|
+
"serving": "./dist-node/serving.mjs"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@volter/editor-sdk": "0.5.66",
|
|
42
|
+
"@volter/editor-project": "0.5.66",
|
|
43
|
+
"typescript": "5.9.3"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"vite": "^6.4.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"esbuild": "0.25.12"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript declared-prop analysis, isolated from the Vite HTTP thread.
|
|
3
|
+
*
|
|
4
|
+
* `ComponentPropResolver` builds a full ts.Program on its first query. That is
|
|
5
|
+
* deliberately real TypeScript semantic analysis, but it is CPU-bound and
|
|
6
|
+
* takes seconds on a cold project. Running it from `setImmediate` does not
|
|
7
|
+
* make it asynchronous: it still freezes the one Node event loop serving the
|
|
8
|
+
* editor. This worker keeps one incremental resolver per project and returns
|
|
9
|
+
* only the ecosystem-native prop descriptions the OID index already carries.
|
|
10
|
+
*
|
|
11
|
+
* The `.ts` extensions below are LOAD-BEARING, not a style slip. `new
|
|
12
|
+
* Worker(new URL('./server/component-prop-worker.ts', …))` hands this file to
|
|
13
|
+
* Node directly: tsx's resolver hooks do not reach a worker thread, so the
|
|
14
|
+
* module is executed by Node's own type stripping, whose ESM resolver demands
|
|
15
|
+
* an explicit extension. Dropping them resolves under tsc and then dies at
|
|
16
|
+
* runtime with ERR_MODULE_NOT_FOUND the first time the editor asks for
|
|
17
|
+
* declared props. `tsconfig.server.json` sets `allowImportingTsExtensions`
|
|
18
|
+
* for exactly this reason.
|
|
19
|
+
*/
|
|
20
|
+
import { parentPort } from 'node:worker_threads';
|
|
21
|
+
import { ComponentPropResolver } from '../src/source/component-prop-types';
|
|
22
|
+
import type { ComponentPropSpec } from '@volter/editor-sdk/source-authoring';
|
|
23
|
+
|
|
24
|
+
interface PropRequest {
|
|
25
|
+
key: string;
|
|
26
|
+
file: string;
|
|
27
|
+
tag: string;
|
|
28
|
+
/** `file` DEFINES `tag` (a prefab about to be dropped, not yet imported
|
|
29
|
+
* anywhere) — answer from the definition instead of a callsite. */
|
|
30
|
+
definition?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ResolveMessage {
|
|
34
|
+
id: number;
|
|
35
|
+
projectRoot: string;
|
|
36
|
+
requests: PropRequest[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const resolvers = new Map<string, ComponentPropResolver>();
|
|
40
|
+
|
|
41
|
+
function resolverFor(projectRoot: string): ComponentPropResolver {
|
|
42
|
+
const existing = resolvers.get(projectRoot);
|
|
43
|
+
if (existing) return existing;
|
|
44
|
+
const resolver = new ComponentPropResolver(projectRoot);
|
|
45
|
+
resolvers.set(projectRoot, resolver);
|
|
46
|
+
return resolver;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (parentPort === null) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
'component-prop-worker is a worker-thread entry point: it must be spawned with `new Worker(...)` and never imported on the main thread.',
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const port = parentPort;
|
|
55
|
+
|
|
56
|
+
port.on('message', (message: ResolveMessage) => {
|
|
57
|
+
try {
|
|
58
|
+
const resolver = resolverFor(message.projectRoot);
|
|
59
|
+
const props: Record<string, ComponentPropSpec[]> = {};
|
|
60
|
+
for (const request of message.requests) {
|
|
61
|
+
props[request.key] = request.definition
|
|
62
|
+
? resolver.propsFor(request.file, request.tag)
|
|
63
|
+
: resolver.propsForTag(request.file, request.tag);
|
|
64
|
+
}
|
|
65
|
+
port.postMessage({ id: message.id, props });
|
|
66
|
+
} catch (error) {
|
|
67
|
+
port.postMessage({
|
|
68
|
+
id: message.id,
|
|
69
|
+
error: error instanceof Error ? error.message : String(error),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
package/serving/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@volter/editor-react`'s server half (`package.json#vgai.serving`, the project-serving door in
|
|
3
|
+
* `@volter/editor-sdk/session/project-serving`): the JSX identity stamp and the `/__ui-source/*`
|
|
4
|
+
* authoring routes over a project's React and React Three Fiber source, and the source answers
|
|
5
|
+
* the kit's region decision, validation and Content index ask of a JSX lane.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ProjectServingModule } from '@volter/editor-sdk/session/project-serving';
|
|
9
|
+
import { analyzeR3fComponentContracts, builtinR3fContractsForSource, sourceDialectEvidence } from '../src/source/oid-transform';
|
|
10
|
+
import { r3fAuthoringDiagnostics } from '../src/source/r3f-project-contracts';
|
|
11
|
+
import { uiOidPlugin } from './ui-oid-plugin';
|
|
12
|
+
|
|
13
|
+
export const servingPlugins: ProjectServingModule['servingPlugins'] = (services) => [uiOidPlugin(services)];
|
|
14
|
+
|
|
15
|
+
export { sourceDialectEvidence };
|
|
16
|
+
|
|
17
|
+
export const sourceDiagnostics: ProjectServingModule['sourceDiagnostics'] = (code, file, options) =>
|
|
18
|
+
r3fAuthoringDiagnostics(code, file, options);
|
|
19
|
+
|
|
20
|
+
export const componentContracts: ProjectServingModule['componentContracts'] = (source, path) =>
|
|
21
|
+
analyzeR3fComponentContracts(source, path, builtinR3fContractsForSource(source, path));
|