@treenity/core 1.0.47 → 3.0.0
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/dist/chain.d.ts +20 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +59 -0
- package/dist/chain.js.map +1 -0
- package/dist/client/handle.d.ts +13 -0
- package/dist/client/handle.d.ts.map +1 -0
- package/dist/client/handle.js +46 -0
- package/dist/client/handle.js.map +1 -0
- package/dist/client/index.d.ts +21 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +5 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/trpc.d.ts +13 -0
- package/dist/client/trpc.d.ts.map +1 -0
- package/dist/client/trpc.js +78 -0
- package/dist/client/trpc.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/comp/handle.d.ts +14 -0
- package/dist/comp/handle.d.ts.map +1 -0
- package/dist/comp/handle.js +21 -0
- package/dist/comp/handle.js.map +1 -0
- package/dist/comp/index.d.ts +42 -0
- package/dist/comp/index.d.ts.map +1 -0
- package/dist/comp/index.js +126 -0
- package/dist/comp/index.js.map +1 -0
- package/dist/comp/needs.d.ts +26 -0
- package/dist/comp/needs.d.ts.map +1 -0
- package/dist/comp/needs.js +101 -0
- package/dist/comp/needs.js.map +1 -0
- package/dist/comp/validate.d.ts +13 -0
- package/dist/comp/validate.d.ts.map +1 -0
- package/dist/comp/validate.js +117 -0
- package/dist/comp/validate.js.map +1 -0
- package/dist/comp.d.ts +2 -0
- package/dist/comp.d.ts.map +1 -0
- package/dist/comp.js +2 -0
- package/dist/comp.js.map +1 -0
- package/dist/contexts/schema/index.d.ts +7 -0
- package/dist/contexts/schema/index.d.ts.map +1 -0
- package/dist/contexts/schema/index.js +2 -0
- package/dist/contexts/schema/index.js.map +1 -0
- package/dist/contexts/schema.d.ts +2 -0
- package/dist/contexts/schema.d.ts.map +1 -0
- package/dist/contexts/schema.js +2 -0
- package/dist/contexts/schema.js.map +1 -0
- package/dist/contexts/service/index.d.ts +31 -0
- package/dist/contexts/service/index.d.ts.map +1 -0
- package/dist/contexts/service/index.js +16 -0
- package/dist/contexts/service/index.js.map +1 -0
- package/dist/contexts/service.d.ts +1 -14
- package/dist/contexts/service.d.ts.map +1 -1
- package/dist/contexts/service.js +2 -0
- package/dist/contexts/service.js.map +1 -0
- package/dist/contexts/telegram/index.d.ts +19 -0
- package/dist/contexts/telegram/index.d.ts.map +1 -0
- package/dist/contexts/telegram/index.js +89 -0
- package/dist/contexts/telegram/index.js.map +1 -0
- package/dist/contexts/text/index.d.ts +7 -0
- package/dist/contexts/text/index.d.ts.map +1 -0
- package/dist/contexts/text/index.js +9 -0
- package/dist/contexts/text/index.js.map +1 -0
- package/dist/contexts/text.d.ts +2 -0
- package/dist/contexts/text.d.ts.map +1 -0
- package/dist/contexts/text.js +2 -0
- package/dist/contexts/text.js.map +1 -0
- package/dist/core/component.d.ts +41 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/component.js +105 -0
- package/dist/core/component.js.map +1 -0
- package/dist/core/context.d.ts +5 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +3 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/path.d.ts +7 -0
- package/dist/core/path.d.ts.map +1 -0
- package/dist/core/path.js +37 -0
- package/dist/core/path.js.map +1 -0
- package/dist/core/registry.d.ts +16 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +100 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core.d.ts +2 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +2 -0
- package/dist/core.js.map +1 -0
- package/dist/log.d.ts +8 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +31 -0
- package/dist/log.js.map +1 -0
- package/dist/mod/discover.d.ts +4 -0
- package/dist/mod/discover.d.ts.map +1 -0
- package/dist/mod/discover.js +103 -0
- package/dist/mod/discover.js.map +1 -0
- package/dist/mod/examples/ticker/seed.d.ts +3 -0
- package/dist/mod/examples/ticker/seed.d.ts.map +1 -0
- package/dist/mod/examples/ticker/seed.js +16 -0
- package/dist/mod/examples/ticker/seed.js.map +1 -0
- package/dist/mod/examples/ticker/service.d.ts +2 -0
- package/dist/mod/examples/ticker/service.d.ts.map +1 -0
- package/dist/mod/examples/ticker/service.js +18 -0
- package/dist/mod/examples/ticker/service.js.map +1 -0
- package/dist/mod/examples/ticker/types.d.ts +16 -0
- package/dist/mod/examples/ticker/types.d.ts.map +1 -0
- package/dist/mod/examples/ticker/types.js +20 -0
- package/dist/mod/examples/ticker/types.js.map +1 -0
- package/dist/mod/examples/ticker/view.d.ts +2 -0
- package/dist/mod/examples/ticker/view.d.ts.map +1 -0
- package/dist/mod/examples/ticker/view.js +10 -0
- package/dist/mod/examples/ticker/view.js.map +1 -0
- package/dist/mod/index.d.ts +11 -0
- package/dist/mod/index.d.ts.map +1 -0
- package/dist/mod/index.js +8 -0
- package/dist/mod/index.js.map +1 -0
- package/dist/mod/loader.d.ts +18 -0
- package/dist/mod/loader.d.ts.map +1 -0
- package/dist/mod/loader.js +154 -0
- package/dist/mod/loader.js.map +1 -0
- package/dist/mod/optimistic.d.ts +34 -0
- package/dist/mod/optimistic.d.ts.map +1 -0
- package/dist/mod/optimistic.js +176 -0
- package/dist/mod/optimistic.js.map +1 -0
- package/dist/mod/prefab.d.ts +18 -0
- package/dist/mod/prefab.d.ts.map +1 -0
- package/dist/mod/prefab.js +42 -0
- package/dist/mod/prefab.js.map +1 -0
- package/dist/mod/tracking.d.ts +8 -0
- package/dist/mod/tracking.d.ts.map +1 -0
- package/dist/mod/tracking.js +44 -0
- package/dist/mod/tracking.js.map +1 -0
- package/dist/mod/types.d.ts +31 -0
- package/dist/mod/types.d.ts.map +1 -0
- package/dist/mod/types.js +5 -0
- package/dist/mod/types.js.map +1 -0
- package/dist/mod.d.ts +2 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +2 -0
- package/dist/mod.js.map +1 -0
- package/dist/mods/autostart/server.d.ts +2 -0
- package/dist/mods/autostart/server.d.ts.map +1 -0
- package/dist/mods/autostart/server.js +2 -0
- package/dist/mods/autostart/server.js.map +1 -0
- package/dist/mods/autostart/service.d.ts +14 -0
- package/dist/mods/autostart/service.d.ts.map +1 -0
- package/dist/mods/autostart/service.js +88 -0
- package/dist/mods/autostart/service.js.map +1 -0
- package/dist/mods/llm/index.d.ts +13 -0
- package/dist/mods/llm/index.d.ts.map +1 -0
- package/dist/mods/llm/index.js +43 -0
- package/dist/mods/llm/index.js.map +1 -0
- package/dist/mods/llm/server.d.ts +2 -0
- package/dist/mods/llm/server.d.ts.map +1 -0
- package/dist/mods/llm/server.js +2 -0
- package/dist/mods/llm/server.js.map +1 -0
- package/dist/mods/mcp/server.d.ts +3 -0
- package/dist/mods/mcp/server.d.ts.map +1 -0
- package/dist/mods/mcp/server.js +3 -0
- package/dist/mods/mcp/server.js.map +1 -0
- package/dist/mods/mcp/service.d.ts +2 -0
- package/dist/mods/mcp/service.d.ts.map +1 -0
- package/dist/mods/mcp/service.js +17 -0
- package/dist/mods/mcp/service.js.map +1 -0
- package/dist/mods/mcp/types.d.ts +5 -0
- package/dist/mods/mcp/types.d.ts.map +1 -0
- package/dist/mods/mcp/types.js +7 -0
- package/dist/mods/mcp/types.js.map +1 -0
- package/dist/mods/treenity/agent-port.d.ts +2 -0
- package/dist/mods/treenity/agent-port.d.ts.map +1 -0
- package/dist/mods/treenity/agent-port.js +76 -0
- package/dist/mods/treenity/agent-port.js.map +1 -0
- package/dist/mods/treenity/groups.d.ts +2 -0
- package/dist/mods/treenity/groups.d.ts.map +1 -0
- package/dist/mods/treenity/groups.js +18 -0
- package/dist/mods/treenity/groups.js.map +1 -0
- package/dist/mods/treenity/mod-type.d.ts +2 -0
- package/dist/mods/treenity/mod-type.d.ts.map +1 -0
- package/dist/mods/treenity/mod-type.js +9 -0
- package/dist/mods/treenity/mod-type.js.map +1 -0
- package/dist/mods/treenity/seed.d.ts +2 -0
- package/dist/mods/treenity/seed.d.ts.map +1 -0
- package/dist/mods/treenity/seed.js +53 -0
- package/dist/mods/treenity/seed.js.map +1 -0
- package/dist/mods/treenity/server.d.ts +5 -0
- package/dist/mods/treenity/server.d.ts.map +1 -0
- package/dist/mods/treenity/server.js +5 -0
- package/dist/mods/treenity/server.js.map +1 -0
- package/dist/mods/treenity/system.d.ts +36 -0
- package/dist/mods/treenity/system.d.ts.map +1 -0
- package/dist/mods/treenity/system.js +61 -0
- package/dist/mods/treenity/system.js.map +1 -0
- package/dist/mods/uix/client.d.ts +3 -0
- package/dist/mods/uix/client.d.ts.map +1 -0
- package/dist/mods/uix/client.js +96 -0
- package/dist/mods/uix/client.js.map +1 -0
- package/dist/mods/uix/compile.d.ts +7 -0
- package/dist/mods/uix/compile.d.ts.map +1 -0
- package/dist/mods/uix/compile.js +94 -0
- package/dist/mods/uix/compile.js.map +1 -0
- package/dist/mods/uix/jsx-parser.d.ts +2 -0
- package/dist/mods/uix/jsx-parser.d.ts.map +1 -0
- package/dist/mods/uix/jsx-parser.js +565 -0
- package/dist/mods/uix/jsx-parser.js.map +1 -0
- package/dist/mods/uix/verify.d.ts +7 -0
- package/dist/mods/uix/verify.d.ts.map +1 -0
- package/dist/mods/uix/verify.js +59 -0
- package/dist/mods/uix/verify.js.map +1 -0
- package/dist/schema/catalog.d.ts +23 -0
- package/dist/schema/catalog.d.ts.map +1 -0
- package/dist/schema/catalog.js +82 -0
- package/dist/schema/catalog.js.map +1 -0
- package/dist/schema/extract-schemas.d.ts +5 -0
- package/dist/schema/extract-schemas.d.ts.map +1 -0
- package/dist/schema/extract-schemas.js +444 -0
- package/dist/schema/extract-schemas.js.map +1 -0
- package/dist/schema/load.d.ts +2 -0
- package/dist/schema/load.d.ts.map +1 -0
- package/dist/schema/load.js +23 -0
- package/dist/schema/load.js.map +1 -0
- package/dist/schema/test-fixture.types.d.ts +2 -0
- package/dist/schema/test-fixture.types.d.ts.map +1 -0
- package/dist/schema/test-fixture.types.js +19 -0
- package/dist/schema/test-fixture.types.js.map +1 -0
- package/dist/schema/test-opaque.d.ts +3 -0
- package/dist/schema/test-opaque.d.ts.map +1 -0
- package/dist/schema/test-opaque.js +43 -0
- package/dist/schema/test-opaque.js.map +1 -0
- package/dist/schema/types.d.ts +37 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +3 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/server/actions.d.ts +35 -0
- package/dist/server/actions.d.ts.map +1 -0
- package/dist/server/actions.js +170 -0
- package/dist/server/actions.js.map +1 -0
- package/dist/server/agent.d.ts +6 -0
- package/dist/server/agent.d.ts.map +1 -0
- package/dist/server/agent.js +15 -0
- package/dist/server/agent.js.map +1 -0
- package/dist/server/auth.d.ts +39 -0
- package/dist/server/auth.d.ts.map +1 -0
- package/dist/server/auth.js +335 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/client.d.ts +183 -0
- package/dist/server/client.d.ts.map +1 -0
- package/dist/server/client.js +22 -0
- package/dist/server/client.js.map +1 -0
- package/dist/server/cookies.d.ts +5 -0
- package/dist/server/cookies.d.ts.map +1 -0
- package/dist/server/cookies.js +24 -0
- package/dist/server/cookies.js.map +1 -0
- package/dist/server/doc-index.d.ts +38 -0
- package/dist/server/doc-index.d.ts.map +1 -0
- package/dist/server/doc-index.js +244 -0
- package/dist/server/doc-index.js.map +1 -0
- package/dist/server/errors.d.ts +7 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/errors.js +11 -0
- package/dist/server/errors.js.map +1 -0
- package/dist/server/factory.d.ts +23 -0
- package/dist/server/factory.d.ts.map +1 -0
- package/dist/server/factory.js +70 -0
- package/dist/server/factory.js.map +1 -0
- package/dist/server/main.d.ts +6 -0
- package/dist/server/main.d.ts.map +1 -0
- package/dist/server/main.js +45 -0
- package/dist/server/main.js.map +1 -0
- package/dist/server/mcp.d.ts +5 -0
- package/dist/server/mcp.d.ts.map +1 -0
- package/dist/server/mcp.js +280 -0
- package/dist/server/mcp.js.map +1 -0
- package/dist/server/migrate.d.ts +3 -0
- package/dist/server/migrate.d.ts.map +1 -0
- package/dist/server/migrate.js +56 -0
- package/dist/server/migrate.js.map +1 -0
- package/dist/server/mod-catalog.d.ts +14 -0
- package/dist/server/mod-catalog.d.ts.map +1 -0
- package/dist/server/mod-catalog.js +40 -0
- package/dist/server/mod-catalog.js.map +1 -0
- package/dist/server/mods-mount.d.ts +4 -0
- package/dist/server/mods-mount.d.ts.map +1 -0
- package/dist/server/mods-mount.js +169 -0
- package/dist/server/mods-mount.js.map +1 -0
- package/dist/server/mount-adapters.d.ts +9 -0
- package/dist/server/mount-adapters.d.ts.map +1 -0
- package/dist/server/mount-adapters.js +75 -0
- package/dist/server/mount-adapters.js.map +1 -0
- package/dist/server/mount.d.ts +3 -0
- package/dist/server/mount.d.ts.map +1 -0
- package/dist/server/mount.js +195 -0
- package/dist/server/mount.js.map +1 -0
- package/dist/server/prefab.d.ts +18 -0
- package/dist/server/prefab.d.ts.map +1 -0
- package/dist/server/prefab.js +70 -0
- package/dist/server/prefab.js.map +1 -0
- package/dist/server/seed/index.d.ts +6 -0
- package/dist/server/seed/index.d.ts.map +1 -0
- package/dist/server/seed/index.js +16 -0
- package/dist/server/seed/index.js.map +1 -0
- package/dist/server/server.d.ts +28 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +117 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/sub.d.ts +34 -0
- package/dist/server/sub.d.ts.map +1 -0
- package/dist/server/sub.js +174 -0
- package/dist/server/sub.js.map +1 -0
- package/dist/server/trpc.d.ts +192 -0
- package/dist/server/trpc.d.ts.map +1 -0
- package/dist/server/trpc.js +319 -0
- package/dist/server/trpc.js.map +1 -0
- package/dist/server/types-mount.d.ts +3 -0
- package/dist/server/types-mount.d.ts.map +1 -0
- package/dist/server/types-mount.js +144 -0
- package/dist/server/types-mount.js.map +1 -0
- package/dist/server/validate.d.ts +3 -0
- package/dist/server/validate.d.ts.map +1 -0
- package/dist/server/validate.js +20 -0
- package/dist/server/validate.js.map +1 -0
- package/dist/server/volatile.d.ts +11 -0
- package/dist/server/volatile.d.ts.map +1 -0
- package/dist/server/volatile.js +26 -0
- package/dist/server/volatile.js.map +1 -0
- package/dist/server/watch.d.ts +23 -0
- package/dist/server/watch.d.ts.map +1 -0
- package/dist/server/watch.js +178 -0
- package/dist/server/watch.js.map +1 -0
- package/dist/tree/cache.d.ts +3 -0
- package/dist/tree/cache.d.ts.map +1 -0
- package/dist/tree/cache.js +48 -0
- package/dist/tree/cache.js.map +1 -0
- package/dist/tree/fs.d.ts +3 -0
- package/dist/tree/fs.d.ts.map +1 -0
- package/dist/tree/fs.js +274 -0
- package/dist/tree/fs.js.map +1 -0
- package/dist/tree/index.d.ts +38 -0
- package/dist/tree/index.d.ts.map +1 -0
- package/dist/tree/index.js +182 -0
- package/dist/tree/index.js.map +1 -0
- package/dist/tree/inflight.d.ts +2 -0
- package/dist/tree/inflight.d.ts.map +1 -0
- package/dist/tree/inflight.js +15 -0
- package/dist/tree/inflight.js.map +1 -0
- package/dist/tree/json-codec.d.ts +2 -0
- package/dist/tree/json-codec.d.ts.map +1 -0
- package/dist/tree/json-codec.js +13 -0
- package/dist/tree/json-codec.js.map +1 -0
- package/dist/tree/mimefs.d.ts +13 -0
- package/dist/tree/mimefs.d.ts.map +1 -0
- package/dist/tree/mimefs.js +124 -0
- package/dist/tree/mimefs.js.map +1 -0
- package/dist/tree/mongo.d.ts +5 -0
- package/dist/tree/mongo.d.ts.map +1 -0
- package/dist/tree/mongo.js +110 -0
- package/dist/tree/mongo.js.map +1 -0
- package/dist/tree/patch.d.ts +30 -0
- package/dist/tree/patch.d.ts.map +1 -0
- package/dist/tree/patch.js +112 -0
- package/dist/tree/patch.js.map +1 -0
- package/dist/tree/query.d.ts +12 -0
- package/dist/tree/query.d.ts.map +1 -0
- package/dist/tree/query.js +61 -0
- package/dist/tree/query.js.map +1 -0
- package/dist/tree/repath.d.ts +3 -0
- package/dist/tree/repath.d.ts.map +1 -0
- package/dist/tree/repath.js +38 -0
- package/dist/tree/repath.js.map +1 -0
- package/dist/tree-chain.d.ts +18 -0
- package/dist/tree-chain.d.ts.map +1 -0
- package/dist/tree-chain.js +109 -0
- package/dist/tree-chain.js.map +1 -0
- package/dist/tree.d.ts +2 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +2 -0
- package/dist/tree.js.map +1 -0
- package/dist/uri.d.ts +11 -0
- package/dist/uri.d.ts.map +1 -0
- package/dist/uri.js +79 -0
- package/dist/uri.js.map +1 -0
- package/package.json +39 -40
- package/src/chain.test.ts +190 -0
- package/src/chain.ts +82 -0
- package/src/client/client.test.ts +192 -0
- package/src/client/handle.ts +53 -0
- package/src/client/index.ts +18 -0
- package/src/client/trpc.ts +91 -0
- package/src/client.ts +1 -0
- package/src/comp/CLAUDE.md +14 -0
- package/src/comp/handle.ts +36 -0
- package/src/comp/index.test.ts +129 -0
- package/src/comp/index.ts +175 -0
- package/src/comp/needs.test.ts +499 -0
- package/src/comp/needs.ts +113 -0
- package/src/comp/validate.test.ts +304 -0
- package/src/comp/validate.ts +125 -0
- package/src/comp.ts +1 -0
- package/src/contexts/schema/index.ts +7 -0
- package/src/contexts/schema.ts +1 -0
- package/src/contexts/service/index.test.ts +323 -0
- package/src/contexts/service/index.ts +43 -0
- package/src/contexts/service.ts +1 -0
- package/src/contexts/telegram/index.ts +115 -0
- package/src/contexts/text/index.test.ts +31 -0
- package/src/contexts/text/index.ts +18 -0
- package/src/contexts/text.ts +1 -0
- package/src/core/component.ts +151 -0
- package/src/core/context.ts +14 -0
- package/src/core/index.test.ts +203 -0
- package/src/core/index.ts +9 -0
- package/src/core/path.ts +35 -0
- package/src/core/registry.ts +115 -0
- package/src/core.ts +1 -0
- package/src/log.test.ts +70 -0
- package/src/log.ts +28 -0
- package/src/mod/discover.test.ts +133 -0
- package/src/mod/discover.ts +100 -0
- package/src/mod/docs/00-index.md +19 -0
- package/src/mod/docs/01-primitives.md +38 -0
- package/src/mod/docs/02-core-api.md +68 -0
- package/src/mod/docs/03-registry.md +30 -0
- package/src/mod/docs/04-store.md +62 -0
- package/src/mod/docs/05-comp.md +111 -0
- package/src/mod/docs/06-actions.md +193 -0
- package/src/mod/docs/07-realtime.md +100 -0
- package/src/mod/docs/08-services.md +33 -0
- package/src/mod/docs/09-mounts.md +43 -0
- package/src/mod/docs/10-acl.md +60 -0
- package/src/mod/docs/11-server.md +62 -0
- package/src/mod/docs/12-conventions.md +65 -0
- package/src/mod/docs/13-example.md +132 -0
- package/src/mod/docs/14-mod-format.md +304 -0
- package/src/mod/docs/15-documenting-types.md +156 -0
- package/src/mod/examples/ticker/seed.ts +19 -0
- package/src/mod/examples/ticker/service.ts +20 -0
- package/src/mod/examples/ticker/ticker.test.ts +18 -0
- package/src/mod/examples/ticker/types.ts +22 -0
- package/src/mod/examples/ticker/view.tsx +19 -0
- package/src/mod/index.ts +12 -0
- package/src/mod/loader.test.ts +168 -0
- package/src/mod/loader.ts +174 -0
- package/src/mod/optimistic.test.ts +446 -0
- package/src/mod/optimistic.ts +210 -0
- package/src/mod/prefab.ts +62 -0
- package/src/mod/tracking.test.ts +59 -0
- package/src/mod/tracking.ts +51 -0
- package/src/mod/types.ts +40 -0
- package/src/mod.ts +1 -0
- package/src/mods/autostart/CLAUDE.md +6 -0
- package/src/mods/autostart/autostart.test.ts +85 -0
- package/src/mods/autostart/server.ts +1 -0
- package/src/mods/autostart/service.ts +98 -0
- package/src/mods/llm/CLAUDE.md +6 -0
- package/src/mods/llm/index.ts +57 -0
- package/src/mods/llm/llm.test.ts +109 -0
- package/src/mods/llm/server.ts +1 -0
- package/src/mods/mcp/CLAUDE.md +6 -0
- package/src/mods/mcp/server.ts +2 -0
- package/src/mods/mcp/service.ts +19 -0
- package/src/mods/mcp/types.ts +7 -0
- package/src/mods/treenity/agent-port.ts +93 -0
- package/src/mods/treenity/groups.ts +19 -0
- package/src/mods/treenity/mod-type.ts +10 -0
- package/src/mods/treenity/seed.ts +56 -0
- package/src/mods/treenity/server.ts +4 -0
- package/src/mods/treenity/system.ts +70 -0
- package/src/mods/uix/CLAUDE.md +7 -0
- package/src/mods/uix/client.ts +117 -0
- package/src/mods/uix/compile.test.ts +228 -0
- package/src/mods/uix/compile.ts +110 -0
- package/src/mods/uix/jsx-parser.test.ts +554 -0
- package/src/mods/uix/jsx-parser.ts +489 -0
- package/src/mods/uix/lazy-load.test.ts +261 -0
- package/src/mods/uix/uix-repomix.md +3509 -0
- package/src/mods/uix/verify.ts +68 -0
- package/src/schema/CLAUDE.md +13 -0
- package/src/schema/catalog.ts +101 -0
- package/src/schema/extract-schemas.test.ts +84 -0
- package/src/schema/extract-schemas.ts +462 -0
- package/src/schema/generated/autostart.json +44 -0
- package/src/schema/generated/board.column.json +25 -0
- package/src/schema/generated/board.task.json +147 -0
- package/src/schema/generated/brahman.action.back.json +12 -0
- package/src/schema/generated/brahman.action.broadcast.json +31 -0
- package/src/schema/generated/brahman.action.call.json +57 -0
- package/src/schema/generated/brahman.action.emittext.json +23 -0
- package/src/schema/generated/brahman.action.eval.json +23 -0
- package/src/schema/generated/brahman.action.file.json +28 -0
- package/src/schema/generated/brahman.action.forward.json +29 -0
- package/src/schema/generated/brahman.action.getvalue.json +28 -0
- package/src/schema/generated/brahman.action.ifelse.json +42 -0
- package/src/schema/generated/brahman.action.keywordselect.json +46 -0
- package/src/schema/generated/brahman.action.message.json +127 -0
- package/src/schema/generated/brahman.action.onerror.json +29 -0
- package/src/schema/generated/brahman.action.page.json +22 -0
- package/src/schema/generated/brahman.action.params.json +36 -0
- package/src/schema/generated/brahman.action.question.json +43 -0
- package/src/schema/generated/brahman.action.remove.json +12 -0
- package/src/schema/generated/brahman.action.resethistory.json +12 -0
- package/src/schema/generated/brahman.action.resetsession.json +12 -0
- package/src/schema/generated/brahman.action.selectlang.json +20 -0
- package/src/schema/generated/brahman.action.setvalue.json +27 -0
- package/src/schema/generated/brahman.action.tag.json +27 -0
- package/src/schema/generated/brahman.bot.json +68 -0
- package/src/schema/generated/brahman.page.json +25 -0
- package/src/schema/generated/brahman.session.json +29 -0
- package/src/schema/generated/brahman.user.json +58 -0
- package/src/schema/generated/cafe.contact.json +56 -0
- package/src/schema/generated/cafe.mail.json +29 -0
- package/src/schema/generated/default.json +15 -0
- package/src/schema/generated/doc.page.json +23 -0
- package/src/schema/generated/examples.demo.generator.json +16 -0
- package/src/schema/generated/examples.demo.sensor.json +35 -0
- package/src/schema/generated/groups.json +20 -0
- package/src/schema/generated/launcher.json +91 -0
- package/src/schema/generated/mcp.server.json +15 -0
- package/src/schema/generated/mindmap.map.json +22 -0
- package/src/schema/generated/sim.agent.json +24 -0
- package/src/schema/generated/sim.ai.json +24 -0
- package/src/schema/generated/sim.config.json +38 -0
- package/src/schema/generated/sim.descriptive.json +26 -0
- package/src/schema/generated/sim.events.json +47 -0
- package/src/schema/generated/sim.item.json +20 -0
- package/src/schema/generated/sim.memory.json +17 -0
- package/src/schema/generated/sim.nearby.json +17 -0
- package/src/schema/generated/sim.position.json +25 -0
- package/src/schema/generated/sim.round.json +64 -0
- package/src/schema/generated/sim.world.json +32 -0
- package/src/schema/generated/t.agent.port.json +74 -0
- package/src/schema/generated/t.llm.json +20 -0
- package/src/schema/generated/t.mod.json +27 -0
- package/src/schema/generated/t3d.animator.json +46 -0
- package/src/schema/generated/t3d.audio.json +58 -0
- package/src/schema/generated/t3d.camera.json +50 -0
- package/src/schema/generated/t3d.collider.json +84 -0
- package/src/schema/generated/t3d.light.json +90 -0
- package/src/schema/generated/t3d.line.json +47 -0
- package/src/schema/generated/t3d.lod.json +28 -0
- package/src/schema/generated/t3d.material.json +131 -0
- package/src/schema/generated/t3d.mesh.json +65 -0
- package/src/schema/generated/t3d.object.json +64 -0
- package/src/schema/generated/t3d.particles.json +109 -0
- package/src/schema/generated/t3d.rigidbody.json +81 -0
- package/src/schema/generated/t3d.scene.json +7 -0
- package/src/schema/generated/t3d.script.json +23 -0
- package/src/schema/generated/t3d.text.json +86 -0
- package/src/schema/generated/t3d.trail.json +45 -0
- package/src/schema/generated/task.json +96 -0
- package/src/schema/generated/test.fixture.json +43 -0
- package/src/schema/generated/ticker.config.json +43 -0
- package/src/schema/generated/ticker.price.json +20 -0
- package/src/schema/generated/todo.item.json +25 -0
- package/src/schema/generated/todo.list.json +33 -0
- package/src/schema/generated/treenity.system.json +259 -0
- package/src/schema/generated/whisper.audio.json +25 -0
- package/src/schema/generated/whisper.checklist.json +17 -0
- package/src/schema/generated/whisper.config.json +30 -0
- package/src/schema/generated/whisper.inbox.json +24 -0
- package/src/schema/generated/whisper.meta.json +35 -0
- package/src/schema/generated/whisper.text.json +16 -0
- package/src/schema/load.ts +24 -0
- package/src/schema/schema.test.ts +86 -0
- package/src/schema/test-fixture.types.ts +21 -0
- package/src/schema/test-opaque.ts +42 -0
- package/src/schema/types.ts +33 -0
- package/src/server/CLAUDE.md +26 -0
- package/src/server/actions.test.ts +272 -0
- package/src/server/actions.ts +274 -0
- package/src/server/agent-sub.test.ts +90 -0
- package/src/server/agent.test.ts +305 -0
- package/src/server/agent.ts +17 -0
- package/src/server/api.test.ts +454 -0
- package/src/server/auth.test.ts +441 -0
- package/src/server/auth.ts +386 -0
- package/src/server/client.ts +24 -0
- package/src/server/conditions.test.ts +128 -0
- package/src/server/cookies.ts +25 -0
- package/src/server/coverage.test.ts +827 -0
- package/src/server/doc-index.ts +286 -0
- package/src/server/e2e.test.ts +966 -0
- package/src/server/errors.ts +11 -0
- package/src/server/factory.ts +99 -0
- package/src/server/main.ts +56 -0
- package/src/server/mcp.ts +326 -0
- package/src/server/migrate.test.ts +123 -0
- package/src/server/migrate.ts +62 -0
- package/src/server/mod-catalog.ts +59 -0
- package/src/server/mods-mount.ts +179 -0
- package/src/server/mount-adapters.ts +82 -0
- package/src/server/mount.parametrized.test.ts +52 -0
- package/src/server/mount.query.test.ts +127 -0
- package/src/server/mount.test.ts +497 -0
- package/src/server/mount.ts +208 -0
- package/src/server/prefab.test.ts +415 -0
- package/src/server/prefab.ts +104 -0
- package/src/server/seed/index.ts +24 -0
- package/src/server/server.ts +153 -0
- package/src/server/stress.test.ts +844 -0
- package/src/server/sub.test.ts +55 -0
- package/src/server/sub.ts +224 -0
- package/src/server/trpc.ts +369 -0
- package/src/server/types-mount.ts +142 -0
- package/src/server/validate.test.ts +91 -0
- package/src/server/validate.ts +22 -0
- package/src/server/volatile.test.ts +140 -0
- package/src/server/volatile.ts +32 -0
- package/src/server/watch.test.ts +594 -0
- package/src/server/watch.ts +202 -0
- package/src/server/workflow.test.ts +82 -0
- package/src/tree/CLAUDE.md +13 -0
- package/src/tree/cache.test.ts +213 -0
- package/src/tree/cache.ts +51 -0
- package/src/tree/fs.test.ts +247 -0
- package/src/tree/fs.ts +251 -0
- package/src/tree/index.test.ts +164 -0
- package/src/tree/index.ts +216 -0
- package/src/tree/inflight.ts +15 -0
- package/src/tree/json-codec.ts +16 -0
- package/src/tree/mimefs.test.ts +289 -0
- package/src/tree/mimefs.ts +142 -0
- package/src/tree/mongo.ts +125 -0
- package/src/tree/patch.test.ts +192 -0
- package/src/tree/patch.ts +133 -0
- package/src/tree/query.test.ts +110 -0
- package/src/tree/query.ts +70 -0
- package/src/tree/repath.test.ts +86 -0
- package/src/tree/repath.ts +53 -0
- package/src/tree-chain.test.ts +723 -0
- package/src/tree-chain.ts +144 -0
- package/src/tree.ts +1 -0
- package/src/uri.test.ts +86 -0
- package/src/uri.ts +82 -0
- package/CHANGELOG.md +0 -305
- package/README.md +0 -18
- package/dist/context.d.ts +0 -41
- package/dist/context.d.ts.map +0 -1
- package/dist/context.mjs +0 -81
- package/dist/context.mjs.map +0 -1
- package/dist/contexts/node-engine.d.ts +0 -12
- package/dist/contexts/node-engine.d.ts.map +0 -1
- package/dist/contexts/node-engine.mjs +0 -7
- package/dist/contexts/node-engine.mjs.map +0 -1
- package/dist/contexts/noflo/types.d.ts +0 -20
- package/dist/contexts/noflo/types.d.ts.map +0 -1
- package/dist/contexts/object.d.ts +0 -11
- package/dist/contexts/object.d.ts.map +0 -1
- package/dist/contexts/object.mjs +0 -15
- package/dist/contexts/object.mjs.map +0 -1
- package/dist/contexts/proto.d.ts +0 -11
- package/dist/contexts/proto.d.ts.map +0 -1
- package/dist/contexts/proto.mjs +0 -7
- package/dist/contexts/proto.mjs.map +0 -1
- package/dist/contexts/react-context.d.ts +0 -21
- package/dist/contexts/react-context.d.ts.map +0 -1
- package/dist/contexts/react-context.mjs +0 -24
- package/dist/contexts/react-context.mjs.map +0 -1
- package/dist/contexts/service.mjs +0 -7
- package/dist/contexts/service.mjs.map +0 -1
- package/dist/get-type-cache.d.ts +0 -2
- package/dist/get-type-cache.d.ts.map +0 -1
- package/dist/get-type-cache.mjs +0 -7
- package/dist/get-type-cache.mjs.map +0 -1
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -10
- package/dist/index.mjs.map +0 -1
- package/dist/link/link.d.ts +0 -25
- package/dist/link/link.d.ts.map +0 -1
- package/dist/link/link.mjs +0 -72
- package/dist/link/link.mjs.map +0 -1
- package/dist/link/link.test.d.ts +0 -2
- package/dist/link/link.test.d.ts.map +0 -1
- package/dist/loading.d.ts +0 -9
- package/dist/loading.d.ts.map +0 -1
- package/dist/meta-type.d.ts +0 -58
- package/dist/meta-type.d.ts.map +0 -1
- package/dist/meta-type.mjs +0 -104
- package/dist/meta-type.mjs.map +0 -1
- package/dist/meta.d.ts +0 -20
- package/dist/meta.d.ts.map +0 -1
- package/dist/meta.mjs +0 -16
- package/dist/meta.mjs.map +0 -1
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/types.d.ts +0 -37
- package/dist/node/types.d.ts.map +0 -1
- package/dist/test/context.test.d.ts +0 -2
- package/dist/test/context.test.d.ts.map +0 -1
- package/dist/types.d.ts +0 -14
- package/dist/types.d.ts.map +0 -1
- package/dist/types.mjs +0 -16
- package/dist/types.mjs.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// UIX Compile — JSX compilation + caching + registration pipeline
|
|
2
|
+
// Turns raw JSX/TSX code string into a React component
|
|
3
|
+
|
|
4
|
+
import { register } from '#core';
|
|
5
|
+
import { Render, RenderContext, RenderField } from '@treenity/react/context';
|
|
6
|
+
import { useChildren, usePath } from '@treenity/react/hooks';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { compileJSX } from './jsx-parser';
|
|
9
|
+
|
|
10
|
+
// Scope injected into dynamic code — what AI components can use
|
|
11
|
+
const SCOPE: Record<string, unknown> = {
|
|
12
|
+
React,
|
|
13
|
+
h: React.createElement,
|
|
14
|
+
Fragment: React.Fragment,
|
|
15
|
+
useState: React.useState,
|
|
16
|
+
useEffect: React.useEffect,
|
|
17
|
+
useMemo: React.useMemo,
|
|
18
|
+
useCallback: React.useCallback,
|
|
19
|
+
useRef: React.useRef,
|
|
20
|
+
Render,
|
|
21
|
+
RenderContext,
|
|
22
|
+
RenderField,
|
|
23
|
+
usePath,
|
|
24
|
+
useChildren,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const cache = new Map<string, React.FC<any>>();
|
|
28
|
+
|
|
29
|
+
// Strip import lines (resolved from scope), extract export default name
|
|
30
|
+
function prepareCode(code: string): { body: string; exportName: string | null } {
|
|
31
|
+
const lines = code.split('\n');
|
|
32
|
+
const body: string[] = [];
|
|
33
|
+
let exportName: string | null = null;
|
|
34
|
+
|
|
35
|
+
for (const line of lines) {
|
|
36
|
+
const trimmed = line.trim();
|
|
37
|
+
|
|
38
|
+
if (trimmed.startsWith('import ')) continue;
|
|
39
|
+
|
|
40
|
+
if (trimmed.startsWith('export default ')) {
|
|
41
|
+
const rest = trimmed.slice('export default '.length).trim();
|
|
42
|
+
// `export default function Foo(` or `export default class Foo` — keep declaration, extract name
|
|
43
|
+
const declMatch = rest.match(/^(function|class)\s+(\w+)/);
|
|
44
|
+
if (declMatch) {
|
|
45
|
+
exportName = declMatch[2];
|
|
46
|
+
body.push(line.replace('export default ', ''));
|
|
47
|
+
} else {
|
|
48
|
+
// `export default Foo;` — just a name reference
|
|
49
|
+
exportName = rest.replace(/;$/, '').trim();
|
|
50
|
+
}
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (trimmed.startsWith('export ')) {
|
|
55
|
+
body.push(line.replace('export ', ''));
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
body.push(line);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return { body: body.join('\n'), exportName };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function compileComponent(
|
|
66
|
+
type: string,
|
|
67
|
+
rawCode: string,
|
|
68
|
+
opts?: { extraScope?: Record<string, unknown>; skipRegister?: boolean },
|
|
69
|
+
): React.FC<any> {
|
|
70
|
+
const cacheKey = type + '\0' + rawCode;
|
|
71
|
+
const cached = cache.get(cacheKey);
|
|
72
|
+
if (cached) return cached;
|
|
73
|
+
|
|
74
|
+
const { body, exportName } = prepareCode(rawCode);
|
|
75
|
+
const jsCode = compileJSX(body);
|
|
76
|
+
|
|
77
|
+
const scope = { ...SCOPE, ...opts?.extraScope };
|
|
78
|
+
|
|
79
|
+
// uix.add() capture for inline mode
|
|
80
|
+
let captured: React.FC<any> | null = null;
|
|
81
|
+
const uix = { add: (comp: React.FC<any>) => { captured = comp; } };
|
|
82
|
+
|
|
83
|
+
const allScope = { ...scope, uix };
|
|
84
|
+
const keys = Object.keys(allScope);
|
|
85
|
+
const vals = Object.values(allScope);
|
|
86
|
+
|
|
87
|
+
const fnBody = exportName
|
|
88
|
+
? `${jsCode}\nreturn ${exportName};`
|
|
89
|
+
: `${jsCode}\nreturn null;`;
|
|
90
|
+
|
|
91
|
+
const fn = new Function(...keys, fnBody);
|
|
92
|
+
const result = fn(...vals);
|
|
93
|
+
|
|
94
|
+
const Component = captured || result;
|
|
95
|
+
if (!Component) throw new Error(`No component found in code for type "${type}". Use uix.add(Comp) or export default.`);
|
|
96
|
+
|
|
97
|
+
cache.set(cacheKey, Component);
|
|
98
|
+
if (!opts?.skipRegister) register(type, 'react', Component);
|
|
99
|
+
return Component;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function invalidateCache(type?: string): void {
|
|
103
|
+
if (type) {
|
|
104
|
+
for (const [k] of cache) {
|
|
105
|
+
if (k.startsWith(type + '\0')) cache.delete(k);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
cache.clear();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
import { compileJSX } from './jsx-parser';
|
|
4
|
+
|
|
5
|
+
// Helper: normalize whitespace for comparison
|
|
6
|
+
const norm = (s: string) => s.replace(/\s+/g, ' ').trim();
|
|
7
|
+
|
|
8
|
+
describe('jsx-parser', () => {
|
|
9
|
+
// ── Basic ──
|
|
10
|
+
|
|
11
|
+
it('1. simple element', () => {
|
|
12
|
+
const r = compileJSX('<div>hello</div>');
|
|
13
|
+
assert.equal(norm(r), norm('h("div", null, "hello")'));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('2. self-closing', () => {
|
|
17
|
+
const r = compileJSX('<br />');
|
|
18
|
+
assert.equal(norm(r), norm('h("br", null)'));
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('3. nested elements', () => {
|
|
22
|
+
const r = compileJSX('<div><span>x</span></div>');
|
|
23
|
+
assert.equal(norm(r), norm('h("div", null, h("span", null, "x"))'));
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('4. multiple children', () => {
|
|
27
|
+
const r = compileJSX('<div><a /><b /><c /></div>');
|
|
28
|
+
const expected = 'h("div", null, h("a", null), h("b", null), h("c", null))';
|
|
29
|
+
assert.equal(norm(r), norm(expected));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// ── Attributes ──
|
|
33
|
+
|
|
34
|
+
it('5. string attr (double quotes)', () => {
|
|
35
|
+
const r = compileJSX('<div className="foo"></div>');
|
|
36
|
+
assert.equal(norm(r), norm('h("div", {"className": "foo"})'));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('6. single-quoted attr', () => {
|
|
40
|
+
const r = compileJSX("<div id='bar'></div>");
|
|
41
|
+
assert.equal(norm(r), norm("h(\"div\", {\"id\": 'bar'})"));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('7. expression attr', () => {
|
|
45
|
+
const r = compileJSX('<input onChange={(e) => set(e.target.value)} />');
|
|
46
|
+
assert.ok(r.includes('"onChange": (e) => set(e.target.value)'), `Got: ${r}`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('8. boolean attr', () => {
|
|
50
|
+
const r = compileJSX('<input disabled />');
|
|
51
|
+
assert.ok(r.includes('"disabled": true'), `Got: ${r}`);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('9. spread props', () => {
|
|
55
|
+
const r = compileJSX('<div {...props} />');
|
|
56
|
+
assert.ok(r.includes('...props'), `Got: ${r}`);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('10. double-brace (object attr)', () => {
|
|
60
|
+
const r = compileJSX('<div style={{color: "red"}} />');
|
|
61
|
+
assert.ok(r.includes('"style": {color: "red"}'), `Got: ${r}`);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('11. template literal attr', () => {
|
|
65
|
+
const r = compileJSX('<div className={`text-${size}`} />');
|
|
66
|
+
assert.ok(r.includes('`text-${size}`'), `Got: ${r}`);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// ── JS Edge Cases ──
|
|
70
|
+
|
|
71
|
+
it('12. comparison in expression — must NOT close tag', () => {
|
|
72
|
+
const r = compileJSX('<button onClick={() => x > 5}>click</button>');
|
|
73
|
+
assert.ok(r.includes('"onClick": () => x > 5'), `Got: ${r}`);
|
|
74
|
+
assert.ok(r.includes('"click"'), `Got: ${r}`);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('13. ternary with JSX', () => {
|
|
78
|
+
const r = compileJSX('{flag ? <A /> : <B />}');
|
|
79
|
+
assert.ok(r.includes('h(A, null)'), `Got: ${r}`);
|
|
80
|
+
assert.ok(r.includes('h(B, null)'), `Got: ${r}`);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('14. arrow function with > in expression child', () => {
|
|
84
|
+
const r = compileJSX('<div>{items.filter(x => x > 0)}</div>');
|
|
85
|
+
assert.ok(r.includes('items.filter(x => x > 0)'), `Got: ${r}`);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('15. string containing tags in attr', () => {
|
|
89
|
+
const r = compileJSX('<div title="<hello>">text</div>');
|
|
90
|
+
assert.ok(r.includes('"title": "<hello>"'), `Got: ${r}`);
|
|
91
|
+
assert.ok(r.includes('"text"'), `Got: ${r}`);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('16. template literal with tags in attr', () => {
|
|
95
|
+
const r = compileJSX('<div data-x={`<${tag}>`} />');
|
|
96
|
+
assert.ok(r.includes('`<${tag}>`'), `Got: ${r}`);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// ── Fragments ──
|
|
100
|
+
|
|
101
|
+
it('17. fragment', () => {
|
|
102
|
+
const r = compileJSX('<><div /><span /></>');
|
|
103
|
+
assert.ok(r.includes('h(Fragment, null'), `Got: ${r}`);
|
|
104
|
+
assert.ok(r.includes('h("div", null)'), `Got: ${r}`);
|
|
105
|
+
assert.ok(r.includes('h("span", null)'), `Got: ${r}`);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('18. React.Fragment with key', () => {
|
|
109
|
+
const r = compileJSX('<React.Fragment key="x"><div /></React.Fragment>');
|
|
110
|
+
assert.ok(r.includes('h(React.Fragment, {"key": "x"}'), `Got: ${r}`);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// ── Components ──
|
|
114
|
+
|
|
115
|
+
it('19. uppercase = component ref', () => {
|
|
116
|
+
const r = compileJSX('<MyComponent foo="bar" />');
|
|
117
|
+
assert.ok(r.includes('h(MyComponent,'), `Got: ${r}`);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('20. lowercase = HTML string', () => {
|
|
121
|
+
const r = compileJSX('<div></div>');
|
|
122
|
+
assert.ok(r.includes('h("div",'), `Got: ${r}`);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('21. dotted component', () => {
|
|
126
|
+
const r = compileJSX('<Ns.Component />');
|
|
127
|
+
assert.ok(r.includes('h(Ns.Component,'), `Got: ${r}`);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// ── Full File ──
|
|
131
|
+
|
|
132
|
+
it('22. function + return + JSX', () => {
|
|
133
|
+
const r = compileJSX('function Foo() { return <div>hi</div>; }');
|
|
134
|
+
assert.ok(r.includes('function Foo()'), `Got: ${r}`);
|
|
135
|
+
assert.ok(r.includes('return h("div", null, "hi")'), `Got: ${r}`);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('23. arrow component', () => {
|
|
139
|
+
const r = compileJSX('const Foo = () => <div>hi</div>');
|
|
140
|
+
assert.ok(r.includes('const Foo = () =>'), `Got: ${r}`);
|
|
141
|
+
assert.ok(r.includes('h("div", null, "hi")'), `Got: ${r}`);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('24. multi-statement body with hooks', () => {
|
|
145
|
+
const code = `const [x, setX] = useState(0);
|
|
146
|
+
return <span>{x}</span>`;
|
|
147
|
+
const r = compileJSX(code);
|
|
148
|
+
assert.ok(r.includes('const [x, setX] = useState(0)'), `Got: ${r}`);
|
|
149
|
+
assert.ok(r.includes('h("span", null, x)'), `Got: ${r}`);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('25. nested function with JSX (map callback)', () => {
|
|
153
|
+
const code = '<ul>{items.map(item => <li key={item.id}>{item.name}</li>)}</ul>';
|
|
154
|
+
const r = compileJSX(code);
|
|
155
|
+
assert.ok(r.includes('h("ul"'), `Got: ${r}`);
|
|
156
|
+
assert.ok(r.includes('h("li"'), `Got: ${r}`);
|
|
157
|
+
assert.ok(r.includes('"key": item.id'), `Got: ${r}`);
|
|
158
|
+
assert.ok(r.includes('item.name'), `Got: ${r}`);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('26. conditional rendering', () => {
|
|
162
|
+
const code = 'if (loading) return <div>Loading</div>;\nreturn <div>Done</div>;';
|
|
163
|
+
const r = compileJSX(code);
|
|
164
|
+
assert.ok(r.includes('h("div", null, "Loading")'), `Got: ${r}`);
|
|
165
|
+
assert.ok(r.includes('h("div", null, "Done")'), `Got: ${r}`);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// ── Text Nodes ──
|
|
169
|
+
|
|
170
|
+
it('27. mixed text + expressions', () => {
|
|
171
|
+
const r = compileJSX('<p>Hello {name}, you have {count} items</p>');
|
|
172
|
+
assert.ok(r.includes('"Hello"'), `Got: ${r}`);
|
|
173
|
+
assert.ok(r.includes('name'), `Got: ${r}`);
|
|
174
|
+
assert.ok(r.includes('count'), `Got: ${r}`);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('28. whitespace-only between tags collapses', () => {
|
|
178
|
+
const r = compileJSX('<div> <span /> </div>');
|
|
179
|
+
// Should not have empty text children
|
|
180
|
+
assert.ok(!r.includes('""'), `Should not have empty strings. Got: ${r}`);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('29. multiline text', () => {
|
|
184
|
+
const r = compileJSX(`<p>
|
|
185
|
+
Hello
|
|
186
|
+
World
|
|
187
|
+
</p>`);
|
|
188
|
+
assert.ok(r.includes('h("p"'), `Got: ${r}`);
|
|
189
|
+
assert.ok(r.includes('Hello'), `Got: ${r}`);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// ── TS Stripping ──
|
|
193
|
+
|
|
194
|
+
it('30. type annotations on params', () => {
|
|
195
|
+
const r = compileJSX('function Foo({ value }: { value: any }) { return <div /> }');
|
|
196
|
+
assert.ok(r.includes('function Foo({ value })'), `Got: ${r}`);
|
|
197
|
+
assert.ok(!r.includes(': { value: any }'), `TS not stripped. Got: ${r}`);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('31. as cast', () => {
|
|
201
|
+
const r = compileJSX('const x = data as string;');
|
|
202
|
+
assert.ok(r.includes('const x = data'), `Got: ${r}`);
|
|
203
|
+
assert.ok(!r.includes('as string'), `TS not stripped. Got: ${r}`);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('31b. as cast after object literal', () => {
|
|
207
|
+
const r = compileJSX('const x = { a: 1 } as Record<string, number>;');
|
|
208
|
+
assert.ok(r.includes('const x = { a: 1 }'), `Got: ${r}`);
|
|
209
|
+
assert.ok(!r.includes('as Record'), `TS not stripped. Got: ${r}`);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('32. interface block stripped', () => {
|
|
213
|
+
const r = compileJSX('interface Props { name: string; age: number; }\nconst x = 1;');
|
|
214
|
+
assert.ok(!r.includes('interface'), `interface not stripped. Got: ${r}`);
|
|
215
|
+
assert.ok(r.includes('const x = 1'), `Code lost. Got: ${r}`);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('33. type alias stripped', () => {
|
|
219
|
+
const r = compileJSX('type MyType = { name: string };\nconst x = 1;');
|
|
220
|
+
assert.ok(!r.includes('type MyType'), `type not stripped. Got: ${r}`);
|
|
221
|
+
assert.ok(r.includes('const x = 1'), `Code lost. Got: ${r}`);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('34. return type annotation', () => {
|
|
225
|
+
const r = compileJSX('function Foo(): JSX.Element { return <div /> }');
|
|
226
|
+
assert.ok(!r.includes(': JSX.Element'), `TS not stripped. Got: ${r}`);
|
|
227
|
+
assert.ok(r.includes('function Foo()'), `Got: ${r}`);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// ── $ identifiers ──
|
|
231
|
+
|
|
232
|
+
it('36. $type in expression not stripped as TS type keyword', () => {
|
|
233
|
+
const r = compileJSX('const x = children.filter(function(c) { return c.$type === "foo"; });');
|
|
234
|
+
assert.ok(r.includes('c.$type'), `$type was stripped. Got: ${r}`);
|
|
235
|
+
assert.ok(r.includes('=== "foo"'), `comparison lost. Got: ${r}`);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('37. $path preserved in JSX attr expression', () => {
|
|
239
|
+
const r = compileJSX('{items.map(function(item) { return <Render key={item.$path} value={item} />; })}');
|
|
240
|
+
assert.ok(r.includes('item.$path'), `$path was stripped. Got: ${r}`);
|
|
241
|
+
assert.ok(r.includes('h(Render,'), `Render not compiled. Got: ${r}`);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('38. JSX inside function(){} callback (depth > 1)', () => {
|
|
245
|
+
const r = compileJSX('{items.map(function(item) { return <div key={item.id}>{item.name}</div>; })}');
|
|
246
|
+
assert.ok(r.includes('h("div"'), `JSX inside callback not transformed. Got: ${r}`);
|
|
247
|
+
assert.ok(r.includes('"key": item.id'), `key attr lost. Got: ${r}`);
|
|
248
|
+
assert.ok(r.includes('item.name'), `child expr lost. Got: ${r}`);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// ── uix.add pattern ──
|
|
252
|
+
|
|
253
|
+
it('35. uix.add inline', () => {
|
|
254
|
+
const r = compileJSX('uix.add(() => <div>test</div>)');
|
|
255
|
+
assert.ok(r.includes('uix.add('), `Got: ${r}`);
|
|
256
|
+
assert.ok(r.includes('h("div", null, "test")'), `Got: ${r}`);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// ── Stress / Benchmark ──
|
|
261
|
+
|
|
262
|
+
describe('jsx-parser perf', () => {
|
|
263
|
+
const SMALL = `
|
|
264
|
+
function Card({ value }: { value: any }) {
|
|
265
|
+
return <div className="p-4 rounded shadow">
|
|
266
|
+
<h2>{value.title}</h2>
|
|
267
|
+
<p>{value.description}</p>
|
|
268
|
+
</div>;
|
|
269
|
+
}
|
|
270
|
+
export default Card;`;
|
|
271
|
+
|
|
272
|
+
const MEDIUM = `
|
|
273
|
+
import { useState, useEffect } from 'react';
|
|
274
|
+
|
|
275
|
+
interface ItemProps {
|
|
276
|
+
value: { title: string; items: any[]; $path: string };
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function Dashboard({ value }: ItemProps) {
|
|
280
|
+
const [filter, setFilter] = useState('');
|
|
281
|
+
const [sort, setSort] = useState<'asc' | 'desc'>('asc');
|
|
282
|
+
const children = useChildren(value.$path);
|
|
283
|
+
|
|
284
|
+
const filtered = children.filter(c =>
|
|
285
|
+
(c as any).title?.toLowerCase().includes(filter.toLowerCase())
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
const sorted = filtered.sort((a, b) => {
|
|
289
|
+
const cmp = ((a as any).title || '').localeCompare((b as any).title || '');
|
|
290
|
+
return sort === 'asc' ? cmp : -cmp;
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
return <div className="space-y-4">
|
|
294
|
+
<div className="flex gap-2">
|
|
295
|
+
<input
|
|
296
|
+
className="border rounded px-3 py-1"
|
|
297
|
+
placeholder="Filter..."
|
|
298
|
+
value={filter}
|
|
299
|
+
onChange={(e) => setFilter(e.target.value)}
|
|
300
|
+
/>
|
|
301
|
+
<button onClick={() => setSort(s => s === 'asc' ? 'desc' : 'asc')}>
|
|
302
|
+
Sort {sort === 'asc' ? '↓' : '↑'}
|
|
303
|
+
</button>
|
|
304
|
+
</div>
|
|
305
|
+
<div className="grid grid-cols-3 gap-4">
|
|
306
|
+
{sorted.map(item => (
|
|
307
|
+
<div key={(item as any).$path} className="p-3 border rounded">
|
|
308
|
+
<Render value={item} />
|
|
309
|
+
</div>
|
|
310
|
+
))}
|
|
311
|
+
</div>
|
|
312
|
+
{sorted.length === 0 && <p className="text-gray-400">No items</p>}
|
|
313
|
+
</div>;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export default Dashboard;`;
|
|
317
|
+
|
|
318
|
+
// Large: repeat a block pattern to simulate ~200 lines of AI-generated code
|
|
319
|
+
const BLOCK = `
|
|
320
|
+
<div className="card p-4 mb-2 border rounded-lg shadow-sm hover:shadow-md transition-shadow">
|
|
321
|
+
<div className="flex items-center justify-between">
|
|
322
|
+
<h3 className="text-lg font-semibold">{item.title}</h3>
|
|
323
|
+
<span className="text-sm text-gray-500">{item.date}</span>
|
|
324
|
+
</div>
|
|
325
|
+
<p className="mt-2 text-gray-600">{item.body}</p>
|
|
326
|
+
<div className="mt-3 flex gap-2">
|
|
327
|
+
<button onClick={() => onEdit(item.id)} className="px-3 py-1 bg-blue-500 text-white rounded">Edit</button>
|
|
328
|
+
<button onClick={() => onDelete(item.id)} className="px-3 py-1 bg-red-500 text-white rounded">Delete</button>
|
|
329
|
+
</div>
|
|
330
|
+
</div>`;
|
|
331
|
+
|
|
332
|
+
const LARGE = `
|
|
333
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
334
|
+
|
|
335
|
+
type Item = { id: string; title: string; body: string; date: string };
|
|
336
|
+
|
|
337
|
+
interface ListProps {
|
|
338
|
+
value: { items: Item[]; $path: string };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function BigList({ value }: ListProps) {
|
|
342
|
+
const [search, setSearch] = useState('');
|
|
343
|
+
const [page, setPage] = useState(0);
|
|
344
|
+
const PAGE_SIZE = 20;
|
|
345
|
+
|
|
346
|
+
const onEdit = useCallback((id: string) => console.log('edit', id), []);
|
|
347
|
+
const onDelete = useCallback((id: string) => console.log('delete', id), []);
|
|
348
|
+
|
|
349
|
+
const items = useMemo(() =>
|
|
350
|
+
value.items
|
|
351
|
+
.filter(item => item.title.toLowerCase().includes(search.toLowerCase()))
|
|
352
|
+
.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE),
|
|
353
|
+
[value.items, search, page]
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
return <div className="space-y-4">
|
|
357
|
+
<input value={search} onChange={(e) => setSearch(e.target.value)}
|
|
358
|
+
className="w-full border rounded px-4 py-2" placeholder="Search..." />
|
|
359
|
+
<div className="space-y-2">
|
|
360
|
+
{items.map(item => (${BLOCK}
|
|
361
|
+
))}
|
|
362
|
+
</div>
|
|
363
|
+
<div className="flex gap-2 justify-center">
|
|
364
|
+
<button disabled={page === 0} onClick={() => setPage(p => p - 1)}
|
|
365
|
+
className="px-4 py-2 border rounded disabled:opacity-50">Prev</button>
|
|
366
|
+
<span className="px-4 py-2">Page {page + 1}</span>
|
|
367
|
+
<button onClick={() => setPage(p => p + 1)}
|
|
368
|
+
className="px-4 py-2 border rounded">Next</button>
|
|
369
|
+
</div>
|
|
370
|
+
</div>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export default BigList;`;
|
|
374
|
+
|
|
375
|
+
function bench(label: string, code: string, iterations: number) {
|
|
376
|
+
// Warmup
|
|
377
|
+
for (let i = 0; i < 10; i++) compileJSX(code);
|
|
378
|
+
|
|
379
|
+
const start = performance.now();
|
|
380
|
+
for (let i = 0; i < iterations; i++) compileJSX(code);
|
|
381
|
+
const elapsed = performance.now() - start;
|
|
382
|
+
|
|
383
|
+
const perOp = elapsed / iterations;
|
|
384
|
+
const lines = code.split('\n').length;
|
|
385
|
+
const chars = code.length;
|
|
386
|
+
return { label, lines, chars, iterations, totalMs: elapsed.toFixed(1), perOpUs: (perOp * 1000).toFixed(0) };
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
it('small component (~8 lines)', () => {
|
|
390
|
+
const r = bench('SMALL', SMALL, 10000);
|
|
391
|
+
console.log(` ${r.label}: ${r.lines} lines, ${r.chars} chars → ${r.perOpUs} µs/op (${r.iterations} iters, ${r.totalMs} ms)`);
|
|
392
|
+
// Must compile in under 500 µs
|
|
393
|
+
assert.ok(Number(r.perOpUs) < 500, `Too slow: ${r.perOpUs} µs`);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it('medium component (~50 lines, TS types, ternary, map)', () => {
|
|
397
|
+
const r = bench('MEDIUM', MEDIUM, 5000);
|
|
398
|
+
console.log(` ${r.label}: ${r.lines} lines, ${r.chars} chars → ${r.perOpUs} µs/op (${r.iterations} iters, ${r.totalMs} ms)`);
|
|
399
|
+
assert.ok(Number(r.perOpUs) < 2000, `Too slow: ${r.perOpUs} µs`);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
it('large component (~70 lines, nested JSX, callbacks)', () => {
|
|
403
|
+
const r = bench('LARGE', LARGE, 2000);
|
|
404
|
+
console.log(` ${r.label}: ${r.lines} lines, ${r.chars} chars → ${r.perOpUs} µs/op (${r.iterations} iters, ${r.totalMs} ms)`);
|
|
405
|
+
assert.ok(Number(r.perOpUs) < 5000, `Too slow: ${r.perOpUs} µs`);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('correctness: large component output is valid', () => {
|
|
409
|
+
const r = compileJSX(LARGE);
|
|
410
|
+
// TS types stripped
|
|
411
|
+
assert.ok(!r.includes('interface ListProps'), `interface not stripped`);
|
|
412
|
+
assert.ok(!r.includes('type Item ='), `type not stripped`);
|
|
413
|
+
// JSX compiled
|
|
414
|
+
assert.ok(r.includes('h("div"'), `No createElement. Got: ${r.slice(0, 200)}`);
|
|
415
|
+
assert.ok(r.includes('h("button"'), `No button. Got: ${r.slice(0, 200)}`);
|
|
416
|
+
// JS logic preserved
|
|
417
|
+
assert.ok(r.includes('useState'), `useState lost`);
|
|
418
|
+
assert.ok(r.includes('useMemo'), `useMemo lost`);
|
|
419
|
+
assert.ok(r.includes('useCallback'), `useCallback lost`);
|
|
420
|
+
assert.ok(r.includes('.filter('), `filter lost`);
|
|
421
|
+
assert.ok(r.includes('.slice('), `slice lost`);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// ── Full pipeline: compileJSX + new Function ──
|
|
425
|
+
|
|
426
|
+
// Minimal prepareCode (mirrors compile.ts logic)
|
|
427
|
+
function prepareCode(code: string): { body: string; exportName: string | null } {
|
|
428
|
+
const lines = code.split('\n');
|
|
429
|
+
const body: string[] = [];
|
|
430
|
+
let exportName: string | null = null;
|
|
431
|
+
for (const line of lines) {
|
|
432
|
+
const trimmed = line.trim();
|
|
433
|
+
if (trimmed.startsWith('import ')) continue;
|
|
434
|
+
if (trimmed.startsWith('export default ')) {
|
|
435
|
+
const rest = trimmed.slice('export default '.length).trim();
|
|
436
|
+
const declMatch = rest.match(/^(function|class)\s+(\w+)/);
|
|
437
|
+
if (declMatch) { exportName = declMatch[2]; body.push(line.replace('export default ', '')); }
|
|
438
|
+
else { exportName = rest.replace(/;$/, '').trim(); }
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (trimmed.startsWith('export ')) { body.push(line.replace('export ', '')); continue; }
|
|
442
|
+
body.push(line);
|
|
443
|
+
}
|
|
444
|
+
return { body: body.join('\n'), exportName };
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Stub scope — real React not needed for benchmarking compilation
|
|
448
|
+
const SCOPE_KEYS = [
|
|
449
|
+
'React', 'h', 'Fragment',
|
|
450
|
+
'useState', 'useEffect', 'useMemo', 'useCallback', 'useRef',
|
|
451
|
+
'Render', 'RenderContext', 'RenderField', 'usePath', 'useChildren', 'uix',
|
|
452
|
+
];
|
|
453
|
+
const noop = () => {};
|
|
454
|
+
const SCOPE_VALS = [
|
|
455
|
+
{ createElement: noop, Fragment: 'Fragment' }, // React stub
|
|
456
|
+
noop, // h
|
|
457
|
+
'Fragment', // Fragment
|
|
458
|
+
noop, noop, noop, noop, noop, // hooks
|
|
459
|
+
noop, noop, noop, noop, noop, // Render, RenderContext, RenderField, usePath, useChildren
|
|
460
|
+
{ add: noop }, // uix
|
|
461
|
+
];
|
|
462
|
+
|
|
463
|
+
function fullPipeline(code: string): Function {
|
|
464
|
+
const { body, exportName } = prepareCode(code);
|
|
465
|
+
const jsCode = compileJSX(body);
|
|
466
|
+
const fnBody = exportName ? `${jsCode}\nreturn ${exportName};` : `${jsCode}\nreturn null;`;
|
|
467
|
+
const fn = new Function(...SCOPE_KEYS, fnBody);
|
|
468
|
+
fn(...SCOPE_VALS); // execute to verify it doesn't throw
|
|
469
|
+
return fn;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function benchFull(label: string, code: string, iterations: number) {
|
|
473
|
+
// Warmup
|
|
474
|
+
for (let i = 0; i < 10; i++) fullPipeline(code);
|
|
475
|
+
|
|
476
|
+
const start = performance.now();
|
|
477
|
+
for (let i = 0; i < iterations; i++) fullPipeline(code);
|
|
478
|
+
const elapsed = performance.now() - start;
|
|
479
|
+
|
|
480
|
+
const perOp = elapsed / iterations;
|
|
481
|
+
const lines = code.split('\n').length;
|
|
482
|
+
const chars = code.length;
|
|
483
|
+
return { label, lines, chars, iterations, totalMs: elapsed.toFixed(1), perOpUs: (perOp * 1000).toFixed(0) };
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
it('full pipeline small (compileJSX + new Function)', () => {
|
|
487
|
+
const r = benchFull('SMALL+fn', SMALL, 5000);
|
|
488
|
+
console.log(` ${r.label}: ${r.lines} lines, ${r.chars} chars → ${r.perOpUs} µs/op (${r.iterations} iters, ${r.totalMs} ms)`);
|
|
489
|
+
assert.ok(Number(r.perOpUs) < 2000, `Too slow: ${r.perOpUs} µs`);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
it('full pipeline medium (compileJSX + new Function)', () => {
|
|
493
|
+
const r = benchFull('MEDIUM+fn', MEDIUM, 2000);
|
|
494
|
+
console.log(` ${r.label}: ${r.lines} lines, ${r.chars} chars → ${r.perOpUs} µs/op (${r.iterations} iters, ${r.totalMs} ms)`);
|
|
495
|
+
assert.ok(Number(r.perOpUs) < 5000, `Too slow: ${r.perOpUs} µs`);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
it('full pipeline large (compileJSX + new Function)', () => {
|
|
499
|
+
const r = benchFull('LARGE+fn', LARGE, 1000);
|
|
500
|
+
console.log(` ${r.label}: ${r.lines} lines, ${r.chars} chars → ${r.perOpUs} µs/op (${r.iterations} iters, ${r.totalMs} ms)`);
|
|
501
|
+
assert.ok(Number(r.perOpUs) < 10000, `Too slow: ${r.perOpUs} µs`);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// ── Correctness: all fixtures produce valid callable Functions ──
|
|
505
|
+
|
|
506
|
+
it('new Function: small returns a function component', () => {
|
|
507
|
+
const result = fullPipeline(SMALL);
|
|
508
|
+
const component = result(...SCOPE_VALS);
|
|
509
|
+
assert.equal(typeof component, 'function', 'Should return a function component');
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('new Function: medium returns a function component', () => {
|
|
513
|
+
const result = fullPipeline(MEDIUM);
|
|
514
|
+
const component = result(...SCOPE_VALS);
|
|
515
|
+
assert.equal(typeof component, 'function', 'Should return a function component');
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it('new Function: large returns a function component', () => {
|
|
519
|
+
const result = fullPipeline(LARGE);
|
|
520
|
+
const component = result(...SCOPE_VALS);
|
|
521
|
+
assert.equal(typeof component, 'function', 'Should return a function component');
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it('new Function: uix.add inline captures component', () => {
|
|
525
|
+
const code = 'uix.add(({ value }) => h("div", null, value.title));';
|
|
526
|
+
const { body, exportName } = prepareCode(code);
|
|
527
|
+
const jsCode = compileJSX(body);
|
|
528
|
+
const fnBody = exportName ? `${jsCode}\nreturn ${exportName};` : `${jsCode}\nreturn null;`;
|
|
529
|
+
let captured: Function | null = null;
|
|
530
|
+
const scopeVals = [
|
|
531
|
+
...SCOPE_VALS.slice(0, -1),
|
|
532
|
+
{ add: (c: Function) => { captured = c; } },
|
|
533
|
+
];
|
|
534
|
+
const fn = new Function(...SCOPE_KEYS, fnBody);
|
|
535
|
+
fn(...scopeVals);
|
|
536
|
+
assert.ok(captured, 'uix.add should capture the component');
|
|
537
|
+
assert.equal(typeof captured, 'function');
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
it('new Function: arrow export default', () => {
|
|
541
|
+
const code = `const Greeting = ({ value }) => h("span", null, value.name);\nexport default Greeting;`;
|
|
542
|
+
const result = fullPipeline(code);
|
|
543
|
+
const component = result(...SCOPE_VALS);
|
|
544
|
+
assert.equal(typeof component, 'function');
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
it('new Function: export default function declaration', () => {
|
|
548
|
+
const code = `export default function MyView({ value }) {\n return h("div", null, value.title);\n}`;
|
|
549
|
+
const result = fullPipeline(code);
|
|
550
|
+
const component = result(...SCOPE_VALS);
|
|
551
|
+
assert.equal(typeof component, 'function');
|
|
552
|
+
assert.equal(component.name, 'MyView');
|
|
553
|
+
});
|
|
554
|
+
});
|