@superblocksteam/vite-plugin-file-sync 2.0.55 → 2.0.56-next.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/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js +394 -2303
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -1
- package/dist/ai-service/agent/subagents/apis/examples.js +34 -35
- package/dist/ai-service/agent/subagents/apis/examples.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts +2 -8
- package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts.map +1 -1
- package/dist/ai-service/agent/subagents/apis/generate-api-source.js +17 -46
- package/dist/ai-service/agent/subagents/apis/generate-api-source.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +0 -1
- package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts.map +1 -1
- package/dist/ai-service/agent/subagents/apis/prompt-builder.js +4 -25
- package/dist/ai-service/agent/subagents/apis/prompt-builder.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/state.js +1 -1
- package/dist/ai-service/agent/subagents/apis/state.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts +1 -1
- package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/subagents/apis/system-prompt.js +134 -173
- package/dist/ai-service/agent/subagents/apis/system-prompt.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/types.d.ts +1 -4
- package/dist/ai-service/agent/subagents/apis/types.d.ts.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.js +14 -31
- package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/build-api.d.ts +1 -6
- package/dist/ai-service/agent/tools/apis/build-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/build-api.js +12 -21
- package/dist/ai-service/agent/tools/apis/build-api.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/finalize-api.d.ts +2 -6
- package/dist/ai-service/agent/tools/apis/finalize-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/finalize-api.js +29 -20
- package/dist/ai-service/agent/tools/apis/finalize-api.js.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.js +4 -9
- package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.d.ts +7 -1
- package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.js +43 -8
- package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +1 -1
- package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-multi-edit-file.js +7 -9
- package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-read-files.d.ts +2 -0
- package/dist/ai-service/agent/tools/build-read-files.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-read-files.js +18 -18
- package/dist/ai-service/agent/tools/build-read-files.js.map +1 -1
- package/dist/ai-service/agent/tools/build-rename-file.d.ts +11 -0
- package/dist/ai-service/agent/tools/build-rename-file.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/build-rename-file.js +103 -0
- package/dist/ai-service/agent/tools/build-rename-file.js.map +1 -0
- package/dist/ai-service/agent/tools/build-validate-icons.d.ts +0 -1
- package/dist/ai-service/agent/tools/build-validate-icons.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-validate-icons.js +0 -6
- package/dist/ai-service/agent/tools/build-validate-icons.js.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.js +5 -6
- package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
- package/dist/ai-service/agent/tools/index.d.ts +0 -10
- package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/index.js +0 -10
- package/dist/ai-service/agent/tools/index.js.map +1 -1
- package/dist/ai-service/agent/tools/shared-helpers.d.ts +1 -7
- package/dist/ai-service/agent/tools/shared-helpers.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/shared-helpers.js +9 -29
- package/dist/ai-service/agent/tools/shared-helpers.js.map +1 -1
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +5 -11
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +1 -2
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +89 -67
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/explain-code-finalize.d.ts +4 -0
- package/dist/ai-service/agent/tools2/tools/explain-code-finalize.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/explain-code-finalize.js +19 -0
- package/dist/ai-service/agent/tools2/tools/explain-code-finalize.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/glob.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/glob.js +15 -6
- package/dist/ai-service/agent/tools2/tools/glob.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +13 -0
- package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata.js +21 -0
- package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/index.d.ts +1 -0
- package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/index.js +1 -0
- package/dist/ai-service/agent/tools2/tools/index.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/ls.d.ts +10 -0
- package/dist/ai-service/agent/tools2/tools/ls.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/ls.js +71 -0
- package/dist/ai-service/agent/tools2/tools/ls.js.map +1 -0
- package/dist/ai-service/agent/utils.d.ts +0 -35
- package/dist/ai-service/agent/utils.d.ts.map +1 -1
- package/dist/ai-service/agent/utils.js +0 -132
- package/dist/ai-service/agent/utils.js.map +1 -1
- package/dist/ai-service/app-interface/file-system-interface.d.ts +1 -1
- package/dist/ai-service/app-interface/file-system-interface.d.ts.map +1 -1
- package/dist/ai-service/app-interface/file-system-interface.js +2 -2
- package/dist/ai-service/app-interface/file-system-interface.js.map +1 -1
- package/dist/ai-service/app-interface/shell.d.ts +5 -0
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +60 -0
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +8 -1
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/clark-provider/clark-chat-settings.d.ts +2 -1
- package/dist/ai-service/clark-provider/clark-chat-settings.d.ts.map +1 -1
- package/dist/ai-service/clark-provider/clark-chat-settings.js +1 -0
- package/dist/ai-service/clark-provider/clark-chat-settings.js.map +1 -1
- package/dist/ai-service/const.d.ts +3 -7
- package/dist/ai-service/const.d.ts.map +1 -1
- package/dist/ai-service/const.js +2 -6
- package/dist/ai-service/const.js.map +1 -1
- package/dist/ai-service/context/app-context.d.ts +2 -1
- package/dist/ai-service/context/app-context.d.ts.map +1 -1
- package/dist/ai-service/context/app-context.js +9 -15
- package/dist/ai-service/context/app-context.js.map +1 -1
- package/dist/ai-service/index.d.ts +4 -4
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +168 -16
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/llm/impl/anthropic.d.ts.map +1 -1
- package/dist/ai-service/llm/impl/anthropic.js +1 -0
- package/dist/ai-service/llm/impl/anthropic.js.map +1 -1
- package/dist/ai-service/llm/impl/clark.d.ts.map +1 -1
- package/dist/ai-service/llm/impl/clark.js +1 -0
- package/dist/ai-service/llm/impl/clark.js.map +1 -1
- package/dist/ai-service/llm/provider.d.ts.map +1 -1
- package/dist/ai-service/llm/provider.js +1 -0
- package/dist/ai-service/llm/provider.js.map +1 -1
- package/dist/ai-service/llm/types.d.ts +1 -1
- package/dist/ai-service/llm/types.d.ts.map +1 -1
- package/dist/ai-service/prompt-builder-service/types.d.ts +0 -2
- package/dist/ai-service/prompt-builder-service/types.d.ts.map +1 -1
- package/dist/ai-service/prompt-builder-service/types.js.map +1 -1
- package/dist/ai-service/prompts/explain-code.d.ts +7 -0
- package/dist/ai-service/prompts/explain-code.d.ts.map +1 -0
- package/dist/ai-service/prompts/explain-code.js +23 -0
- package/dist/ai-service/prompts/explain-code.js.map +1 -0
- package/dist/ai-service/state-machine/clark-fsm.d.ts +0 -2
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +16 -16
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +39 -4
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
- package/dist/ai-service/state-machine/mocks.js +1 -0
- package/dist/ai-service/state-machine/mocks.js.map +1 -1
- package/dist/ai-service/test-utils/app-generation-mocks/orders-app.d.ts +1 -1
- package/dist/ai-service/test-utils/app-generation-mocks/orders-app.d.ts.map +1 -1
- package/dist/ai-service/test-utils/app-generation-mocks/orders-app.js +0 -7
- package/dist/ai-service/test-utils/app-generation-mocks/orders-app.js.map +1 -1
- package/dist/ai-service/test-utils/app-generation-mocks/smoketest.d.ts +1 -1
- package/dist/ai-service/test-utils/app-generation-mocks/smoketest.d.ts.map +1 -1
- package/dist/ai-service/test-utils/app-generation-mocks/smoketest.js +0 -8
- package/dist/ai-service/test-utils/app-generation-mocks/smoketest.js.map +1 -1
- package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts.map +1 -1
- package/dist/ai-service/transform/api-builder/to-sdk-transformer.js +0 -15
- package/dist/ai-service/transform/api-builder/to-sdk-transformer.js.map +1 -1
- package/dist/ai-service/transform/api-builder/to-yaml-transformer.d.ts.map +1 -1
- package/dist/ai-service/transform/api-builder/to-yaml-transformer.js +0 -13
- package/dist/ai-service/transform/api-builder/to-yaml-transformer.js.map +1 -1
- package/dist/ai-service/types.d.ts +2 -2
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/util/json-stream-parser.d.ts +20 -0
- package/dist/ai-service/util/json-stream-parser.d.ts.map +1 -0
- package/dist/ai-service/util/json-stream-parser.js +139 -0
- package/dist/ai-service/util/json-stream-parser.js.map +1 -0
- package/dist/binding-extraction/extract-identifiers.d.ts +1 -5
- package/dist/binding-extraction/extract-identifiers.d.ts.map +1 -1
- package/dist/binding-extraction/extract-identifiers.js +78 -15
- package/dist/binding-extraction/extract-identifiers.js.map +1 -1
- package/dist/binding-extraction/index.d.ts +1 -1
- package/dist/binding-extraction/index.d.ts.map +1 -1
- package/dist/binding-extraction/index.js +1 -1
- package/dist/binding-extraction/index.js.map +1 -1
- package/dist/binding-extraction/{extract-js-identifiers.d.ts → js-identifiers.d.ts} +2 -1
- package/dist/binding-extraction/js-identifiers.d.ts.map +1 -0
- package/dist/binding-extraction/{extract-js-identifiers.js → js-identifiers.js} +81 -1
- package/dist/binding-extraction/js-identifiers.js.map +1 -0
- package/dist/binding-extraction/python-identifiers.d.ts +13 -0
- package/dist/binding-extraction/python-identifiers.d.ts.map +1 -0
- package/dist/binding-extraction/{extract-py-identifiers.js → python-identifiers.js} +155 -1
- package/dist/binding-extraction/python-identifiers.js.map +1 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +9 -15
- package/dist/codegen.js.map +1 -1
- package/dist/components-manager.d.ts +12 -13
- package/dist/components-manager.d.ts.map +1 -1
- package/dist/components-manager.js +78 -139
- package/dist/components-manager.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +164 -326
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-helpers.d.ts +2 -2
- package/dist/file-system-helpers.d.ts.map +1 -1
- package/dist/file-system-helpers.js +6 -4
- package/dist/file-system-helpers.js.map +1 -1
- package/dist/file-system-manager.d.ts +7 -33
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +185 -594
- package/dist/file-system-manager.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/inject-no-select.d.ts +15 -0
- package/dist/inject-no-select.d.ts.map +1 -0
- package/dist/inject-no-select.js +173 -0
- package/dist/inject-no-select.js.map +1 -0
- package/dist/injected-index.d.ts +0 -1
- package/dist/injected-index.d.ts.map +1 -1
- package/dist/injected-index.js +0 -1
- package/dist/injected-index.js.map +1 -1
- package/dist/lock-service/activity-tracker.d.ts.map +1 -1
- package/dist/lock-service/activity-tracker.js +4 -1
- package/dist/lock-service/activity-tracker.js.map +1 -1
- package/dist/parsing/entity/to-code-entity.d.ts.map +1 -1
- package/dist/parsing/entity/to-code-entity.js +3 -4
- package/dist/parsing/entity/to-code-entity.js.map +1 -1
- package/dist/parsing/entity/to-value-entity.d.ts.map +1 -1
- package/dist/parsing/entity/to-value-entity.js +19 -13
- package/dist/parsing/entity/to-value-entity.js.map +1 -1
- package/dist/parsing/ids.d.ts +0 -1
- package/dist/parsing/ids.d.ts.map +1 -1
- package/dist/parsing/ids.js +3 -4
- package/dist/parsing/ids.js.map +1 -1
- package/dist/parsing/imports.d.ts.map +1 -1
- package/dist/parsing/imports.js +0 -10
- package/dist/parsing/imports.js.map +1 -1
- package/dist/parsing/index.d.ts +0 -1
- package/dist/parsing/index.d.ts.map +1 -1
- package/dist/parsing/index.js +0 -1
- package/dist/parsing/index.js.map +1 -1
- package/dist/parsing/jsx.d.ts.map +1 -1
- package/dist/parsing/jsx.js +50 -22
- package/dist/parsing/jsx.js.map +1 -1
- package/dist/parsing/page.d.ts +0 -1
- package/dist/parsing/page.d.ts.map +1 -1
- package/dist/parsing/page.js +55 -32
- package/dist/parsing/page.js.map +1 -1
- package/dist/parsing/properties.d.ts.map +1 -1
- package/dist/parsing/properties.js +45 -15
- package/dist/parsing/properties.js.map +1 -1
- package/dist/parsing/template/index.js +1 -1
- package/dist/parsing/template/index.js.map +1 -1
- package/dist/parsing/template/to-code-template.d.ts +1 -2
- package/dist/parsing/template/to-code-template.d.ts.map +1 -1
- package/dist/parsing/template/to-code-template.js +2 -3
- package/dist/parsing/template/to-code-template.js.map +1 -1
- package/dist/parsing/type-parsing-registry.d.ts +0 -1
- package/dist/parsing/type-parsing-registry.d.ts.map +1 -1
- package/dist/parsing/type-parsing-registry.js +0 -2
- package/dist/parsing/type-parsing-registry.js.map +1 -1
- package/dist/parsing/util.d.ts.map +1 -1
- package/dist/parsing/util.js +22 -5
- package/dist/parsing/util.js.map +1 -1
- package/dist/plugin-options.d.ts +8 -1
- package/dist/plugin-options.d.ts.map +1 -1
- package/dist/plugin-options.js.map +1 -1
- package/dist/refactor/javascript.js +1 -1
- package/dist/refactor/javascript.js.map +1 -1
- package/dist/rename-manager.d.ts.map +1 -1
- package/dist/rename-manager.js +1 -2
- package/dist/rename-manager.js.map +1 -1
- package/dist/router-parser.d.ts +35 -0
- package/dist/router-parser.d.ts.map +1 -0
- package/dist/router-parser.js +490 -0
- package/dist/router-parser.js.map +1 -0
- package/dist/socket-manager.d.ts +3 -3
- package/dist/socket-manager.d.ts.map +1 -1
- package/dist/socket-manager.js +14 -15
- package/dist/socket-manager.js.map +1 -1
- package/dist/source-tracker.d.ts +9 -77
- package/dist/source-tracker.d.ts.map +1 -1
- package/dist/source-tracker.js +83 -374
- package/dist/source-tracker.js.map +1 -1
- package/dist/util/operation-queue.d.ts +3 -0
- package/dist/util/operation-queue.d.ts.map +1 -1
- package/dist/util/operation-queue.js +5 -0
- package/dist/util/operation-queue.js.map +1 -1
- package/dist/util.d.ts +13 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +49 -28
- package/dist/util.js.map +1 -1
- package/dist/vite-plugin-yaml-types.d.ts +9 -0
- package/dist/vite-plugin-yaml-types.d.ts.map +1 -0
- package/dist/vite-plugin-yaml-types.js +114 -0
- package/dist/vite-plugin-yaml-types.js.map +1 -0
- package/package.json +8 -7
- package/dist/ai-service/agent/tools/build-add-event.d.ts +0 -14
- package/dist/ai-service/agent/tools/build-add-event.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-add-event.js +0 -44
- package/dist/ai-service/agent/tools/build-add-event.js.map +0 -1
- package/dist/ai-service/agent/tools/build-add-state-var.d.ts +0 -16
- package/dist/ai-service/agent/tools/build-add-state-var.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-add-state-var.js +0 -62
- package/dist/ai-service/agent/tools/build-add-state-var.js.map +0 -1
- package/dist/ai-service/agent/tools/build-add-timer.d.ts +0 -16
- package/dist/ai-service/agent/tools/build-add-timer.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-add-timer.js +0 -46
- package/dist/ai-service/agent/tools/build-add-timer.js.map +0 -1
- package/dist/ai-service/agent/tools/build-create-page.d.ts +0 -10
- package/dist/ai-service/agent/tools/build-create-page.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-create-page.js +0 -57
- package/dist/ai-service/agent/tools/build-create-page.js.map +0 -1
- package/dist/ai-service/agent/tools/build-list-available-components.d.ts +0 -9
- package/dist/ai-service/agent/tools/build-list-available-components.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-list-available-components.js +0 -55
- package/dist/ai-service/agent/tools/build-list-available-components.js.map +0 -1
- package/dist/ai-service/agent/tools/build-register-component-name.d.ts +0 -9
- package/dist/ai-service/agent/tools/build-register-component-name.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-register-component-name.js +0 -53
- package/dist/ai-service/agent/tools/build-register-component-name.js.map +0 -1
- package/dist/ai-service/agent/tools/build-rename-page.d.ts +0 -9
- package/dist/ai-service/agent/tools/build-rename-page.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-rename-page.js +0 -50
- package/dist/ai-service/agent/tools/build-rename-page.js.map +0 -1
- package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts +0 -25
- package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-set-api-triggers.js +0 -266
- package/dist/ai-service/agent/tools/build-set-api-triggers.js.map +0 -1
- package/dist/ai-service/agent/tools/build-update-state-var.d.ts +0 -16
- package/dist/ai-service/agent/tools/build-update-state-var.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/build-update-state-var.js +0 -67
- package/dist/ai-service/agent/tools/build-update-state-var.js.map +0 -1
- package/dist/ai-service/agent/tools/study-current-app-state.d.ts +0 -20
- package/dist/ai-service/agent/tools/study-current-app-state.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/study-current-app-state.js +0 -20
- package/dist/ai-service/agent/tools/study-current-app-state.js.map +0 -1
- package/dist/binding-extraction/extract-js-identifiers.d.ts.map +0 -1
- package/dist/binding-extraction/extract-js-identifiers.js.map +0 -1
- package/dist/binding-extraction/extract-py-identifiers.d.ts +0 -4
- package/dist/binding-extraction/extract-py-identifiers.d.ts.map +0 -1
- package/dist/binding-extraction/extract-py-identifiers.js.map +0 -1
- package/dist/component-docs-service/index.d.ts +0 -37
- package/dist/component-docs-service/index.d.ts.map +0 -1
- package/dist/component-docs-service/index.js +0 -118
- package/dist/component-docs-service/index.js.map +0 -1
- package/dist/parsing/events/index.d.ts +0 -5
- package/dist/parsing/events/index.d.ts.map +0 -1
- package/dist/parsing/events/index.js +0 -7
- package/dist/parsing/events/index.js.map +0 -1
- package/dist/parsing/events/to-code-events.d.ts +0 -3
- package/dist/parsing/events/to-code-events.d.ts.map +0 -1
- package/dist/parsing/events/to-code-events.js +0 -147
- package/dist/parsing/events/to-code-events.js.map +0 -1
- package/dist/parsing/events/to-value-events.d.ts +0 -10
- package/dist/parsing/events/to-value-events.d.ts.map +0 -1
- package/dist/parsing/events/to-value-events.js +0 -473
- package/dist/parsing/events/to-value-events.js.map +0 -1
- package/dist/parsing/scope.d.ts +0 -103
- package/dist/parsing/scope.d.ts.map +0 -1
- package/dist/parsing/scope.js +0 -902
- package/dist/parsing/scope.js.map +0 -1
- package/dist/routing.d.ts +0 -6
- package/dist/routing.d.ts.map +0 -1
- package/dist/routing.js +0 -169
- package/dist/routing.js.map +0 -1
- package/dist/sb-scope-manager.d.ts +0 -121
- package/dist/sb-scope-manager.d.ts.map +0 -1
- package/dist/sb-scope-manager.js +0 -678
- package/dist/sb-scope-manager.js.map +0 -1
package/dist/source-tracker.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { parse } from "@babel/parser";
|
|
3
3
|
import * as t from "@babel/types";
|
|
4
|
-
import { isPropertyInfo,
|
|
5
|
-
import { SbEntityType, } from "@superblocksteam/library-shared/types";
|
|
4
|
+
import { isPropertyInfo, splitJSPath, splitJSPathAdvanced, } from "@superblocksteam/library-shared";
|
|
6
5
|
import { format } from "prettier";
|
|
7
6
|
import { generateJSXAttribute, generateJSXElement, writeNestedProperty, } from "./codegen.js";
|
|
8
7
|
import { ComponentsManager } from "./components-manager.js";
|
|
9
|
-
import { SCOPE_FILE } from "./file-system-helpers.js";
|
|
10
8
|
import { generate } from "./generate.js";
|
|
11
9
|
import { generatePredictableId } from "./ids.js";
|
|
12
10
|
import { getSbElementId, setSbElementId, supplementElementIds, } from "./parsing/ids.js";
|
|
13
11
|
import { getRequiredImportsForProperty, EXTERNAL_LIBRARY_OPTIONS, } from "./parsing/imports.js";
|
|
14
|
-
import { getDescriptiveName, getJSXAttributeName, getVariableReferences,
|
|
15
|
-
import { getTagName, addImport, extractImportsFromAst,
|
|
16
|
-
import { deleteEntityInAst } from "./refactor/entities.js";
|
|
12
|
+
import { getDescriptiveName, getJSXAttributeName, getVariableReferences, } from "./parsing/jsx.js";
|
|
13
|
+
import { getTagName, addImport, extractImportsFromAst, } from "./parsing/util.js";
|
|
17
14
|
import { RenameManager } from "./rename-manager.js";
|
|
18
|
-
import { SbScopeManager } from "./sb-scope-manager.js";
|
|
19
15
|
import { getErrorMeta, getLogger } from "./util/logger.js";
|
|
16
|
+
import { getScopeIdFromName } from "./util.js";
|
|
20
17
|
const ATTRIBUTE_TYPES_WITH_STATE_ACCESS = ["COMPUTED", "TEMPLATE", "EVENT"];
|
|
21
18
|
// File Explanation:
|
|
22
19
|
// This file is responsible for tracking the source code of the application.
|
|
@@ -25,17 +22,12 @@ const ATTRIBUTE_TYPES_WITH_STATE_ACCESS = ["COMPUTED", "TEMPLATE", "EVENT"];
|
|
|
25
22
|
// This information is used by the source code editor to provide features like drag and drop and property editing.
|
|
26
23
|
export class SourceTracker {
|
|
27
24
|
renameManager = new RenameManager();
|
|
28
|
-
sbScopeManager;
|
|
29
25
|
elementToLocation = {};
|
|
30
26
|
elementToFilePath = {};
|
|
31
|
-
scopeIdToFilePath = {};
|
|
32
|
-
sbScopeNamesToFilePath = {};
|
|
33
27
|
newlyAddedCount = 0;
|
|
34
28
|
fileToMeta = {};
|
|
35
29
|
changedFiles = new Set();
|
|
36
|
-
constructor(
|
|
37
|
-
this.sbScopeManager = new SbScopeManager(this, tracer);
|
|
38
|
-
}
|
|
30
|
+
constructor(_tracer) { }
|
|
39
31
|
getCurrentFiles() {
|
|
40
32
|
return this.fileToMeta;
|
|
41
33
|
}
|
|
@@ -90,18 +82,8 @@ export class SourceTracker {
|
|
|
90
82
|
deleteElementToFilePath(el) {
|
|
91
83
|
delete this.elementToFilePath[el];
|
|
92
84
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
identifier: pageName,
|
|
96
|
-
type: "name",
|
|
97
|
-
});
|
|
98
|
-
return scopeDefinition;
|
|
99
|
-
}
|
|
100
|
-
getScopeDefinitionAndFilePathByNameOrId({ identifier, type, }) {
|
|
101
|
-
return this.sbScopeManager.getScopeDefinitionAndFilePathByNameOrId({
|
|
102
|
-
identifier,
|
|
103
|
-
type,
|
|
104
|
-
});
|
|
85
|
+
getScopeIdForPage(pageName) {
|
|
86
|
+
return getScopeIdFromName(pageName);
|
|
105
87
|
}
|
|
106
88
|
parseJsxFromEntrypoint({ files, }) {
|
|
107
89
|
const parsedAsts = {};
|
|
@@ -129,7 +111,6 @@ export class SourceTracker {
|
|
|
129
111
|
code,
|
|
130
112
|
}));
|
|
131
113
|
const parsedAsts = this.parseJsxFromEntrypoint({
|
|
132
|
-
// entryPointFilePath: rootDir + "/pages/page1/_index.tsx",
|
|
133
114
|
files: fileContents,
|
|
134
115
|
});
|
|
135
116
|
Object.entries(parsedAsts).forEach(([file, ast]) => {
|
|
@@ -144,29 +125,23 @@ export class SourceTracker {
|
|
|
144
125
|
imports: extractImportsFromAst(ast),
|
|
145
126
|
};
|
|
146
127
|
});
|
|
147
|
-
//
|
|
148
|
-
// we've done a move/refactor of a named scope (pages)
|
|
149
|
-
this.sbScopeManager.parseScopes(this.fileToMeta);
|
|
128
|
+
// Parse JSX elements and track their locations
|
|
150
129
|
Object.entries(parsedAsts).forEach(([file, ast]) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.elementToFilePath[id] = file;
|
|
161
|
-
});
|
|
162
|
-
}
|
|
130
|
+
const { idMap } = supplementElementIds({
|
|
131
|
+
fileName: file,
|
|
132
|
+
ast,
|
|
133
|
+
shouldModifyAst: false,
|
|
134
|
+
});
|
|
135
|
+
idMap.forEach((path, id) => {
|
|
136
|
+
this.elementToLocation[id] = path;
|
|
137
|
+
this.elementToFilePath[id] = file;
|
|
138
|
+
});
|
|
163
139
|
});
|
|
164
140
|
};
|
|
165
141
|
handleNonVisualChangeByDeletingIds = async (fileName, fileContents) => {
|
|
166
142
|
const extension = path.extname(fileName);
|
|
167
143
|
if (extension !== ".ts" && extension !== ".tsx")
|
|
168
144
|
return;
|
|
169
|
-
const existingFile = fileName in this.fileToMeta;
|
|
170
145
|
try {
|
|
171
146
|
const astMap = this.parseJsxFromEntrypoint({
|
|
172
147
|
files: [{ fileName, code: fileContents }],
|
|
@@ -192,36 +167,15 @@ export class SourceTracker {
|
|
|
192
167
|
delete this.elementToLocation[key];
|
|
193
168
|
delete this.elementToFilePath[key];
|
|
194
169
|
});
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
imports: extractImportsFromAst(ast),
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
changedFiles.push(fileName);
|
|
208
|
-
}
|
|
209
|
-
// scope file is handled by the sbScopeManager
|
|
210
|
-
if (!fileName.endsWith(SCOPE_FILE)) {
|
|
211
|
-
const { idMap } = supplementElementIds({
|
|
212
|
-
fileName,
|
|
213
|
-
ast,
|
|
214
|
-
shouldModifyAst: false,
|
|
215
|
-
});
|
|
216
|
-
idMap.forEach((path, id) => {
|
|
217
|
-
this.elementToLocation[id] = path;
|
|
218
|
-
this.elementToFilePath[id] = fileName;
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
changedFiles.forEach((file) => {
|
|
222
|
-
if (file !== fileName) {
|
|
223
|
-
this.changedFiles.add(file);
|
|
224
|
-
}
|
|
170
|
+
// Parse JSX elements and track their locations
|
|
171
|
+
const { idMap } = supplementElementIds({
|
|
172
|
+
fileName,
|
|
173
|
+
ast,
|
|
174
|
+
shouldModifyAst: false,
|
|
175
|
+
});
|
|
176
|
+
idMap.forEach((path, id) => {
|
|
177
|
+
this.elementToLocation[id] = path;
|
|
178
|
+
this.elementToFilePath[id] = fileName;
|
|
225
179
|
});
|
|
226
180
|
// Mark the file as changed
|
|
227
181
|
this.changedFiles.add(fileName);
|
|
@@ -240,18 +194,6 @@ export class SourceTracker {
|
|
|
240
194
|
delete this.elementToFilePath[id];
|
|
241
195
|
}
|
|
242
196
|
});
|
|
243
|
-
// Clean up sb scope mappings
|
|
244
|
-
Object.entries(this.sbScopeNamesToFilePath).forEach(([scopeName, info]) => {
|
|
245
|
-
if (info.filePath === fileName) {
|
|
246
|
-
delete this.sbScopeNamesToFilePath[scopeName];
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
// Clean up scope ID mappings
|
|
250
|
-
Object.entries(this.scopeIdToFilePath).forEach(([scopeId, path]) => {
|
|
251
|
-
if (path === fileName) {
|
|
252
|
-
delete this.scopeIdToFilePath[scopeId];
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
197
|
};
|
|
256
198
|
updateFileContents(filePath, code) {
|
|
257
199
|
const existingFile = this.fileToMeta[filePath];
|
|
@@ -343,132 +285,15 @@ export class SourceTracker {
|
|
|
343
285
|
throw new Error("Error updating source tracker during move" + e.message);
|
|
344
286
|
}
|
|
345
287
|
};
|
|
346
|
-
addApi = async ({
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
type: "name",
|
|
350
|
-
});
|
|
351
|
-
if (!scopeDefinition || !scopeFilePath) {
|
|
352
|
-
throw new Error("Scope not found for page " + pageName);
|
|
353
|
-
}
|
|
354
|
-
if (scopeDefinition.entityNames.includes(apiName)) {
|
|
355
|
-
getLogger().warn(`API name ${apiName} already exists in scope for page ${pageName}. Ignoring scope update.`);
|
|
356
|
-
return scopeDefinition.id;
|
|
357
|
-
}
|
|
358
|
-
const changedFiles = this.sbScopeManager.addScopeEntity(scopeDefinition.id, {
|
|
359
|
-
type: SbEntityType.API,
|
|
360
|
-
name: apiName,
|
|
361
|
-
attributes: {},
|
|
362
|
-
});
|
|
363
|
-
changedFiles.forEach((file) => {
|
|
364
|
-
this.changedFiles.add(file);
|
|
365
|
-
});
|
|
366
|
-
return scopeDefinition.id;
|
|
367
|
-
};
|
|
368
|
-
deleteApi = ({ pageName, apiName, }) => {
|
|
369
|
-
const { scopeDefinition, filePath: scopeFilePath } = this.sbScopeManager.getScopeDefinitionAndFilePathByNameOrId({
|
|
370
|
-
identifier: pageName,
|
|
371
|
-
type: "name",
|
|
372
|
-
});
|
|
373
|
-
if (!scopeDefinition || !scopeFilePath) {
|
|
374
|
-
throw new Error("Scope not found for page " + pageName);
|
|
375
|
-
}
|
|
376
|
-
const entityId = scopeDefinition.scopeNameToEntityId[apiName];
|
|
377
|
-
if (!entityId) {
|
|
378
|
-
getLogger().warn("Entity ID not found for API " + apiName);
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const { changedFiles } = this.sbScopeManager.deleteScopeEntity(entityId);
|
|
382
|
-
const scopeFolder = path.dirname(scopeFilePath);
|
|
383
|
-
for (const filePath of Object.keys(this.fileToMeta)) {
|
|
384
|
-
if (filePath.startsWith(scopeFolder) && filePath.endsWith(".tsx")) {
|
|
385
|
-
const currentFile = this.fileToMeta[filePath];
|
|
386
|
-
if (!currentFile || !currentFile.ast) {
|
|
387
|
-
throw new Error(`File not found for element ${filePath}`);
|
|
388
|
-
}
|
|
389
|
-
deleteEntityInAst({ entityName: apiName, ast: currentFile.ast });
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
changedFiles.forEach((file) => {
|
|
393
|
-
this.changedFiles.add(file);
|
|
394
|
-
});
|
|
395
|
-
return scopeDefinition.id;
|
|
396
|
-
};
|
|
397
|
-
addEntity = ({ scopeId, entity, }) => {
|
|
398
|
-
const changedFiles = this.sbScopeManager.addScopeEntity(scopeId, entity);
|
|
399
|
-
changedFiles.forEach((file) => {
|
|
400
|
-
this.changedFiles.add(file);
|
|
401
|
-
});
|
|
402
|
-
};
|
|
403
|
-
updateEntity = (payload) => {
|
|
404
|
-
const changedFile = this.sbScopeManager.updateScopeEntity(payload);
|
|
405
|
-
this.changedFiles.add(changedFile);
|
|
406
|
-
};
|
|
407
|
-
deleteEntity = ({ entityId, }) => {
|
|
408
|
-
const { changedFiles, deletedEntitiesNames } = this.sbScopeManager.deleteScopeEntity(entityId);
|
|
409
|
-
changedFiles.forEach((file) => {
|
|
410
|
-
this.changedFiles.add(file);
|
|
411
|
-
});
|
|
412
|
-
return deletedEntitiesNames[0];
|
|
413
|
-
};
|
|
414
|
-
checkImportInFilesForNewName = ({ entityId, newName, oldName, scopeName, }) => {
|
|
415
|
-
const referencingFiles = this.sbScopeManager.getReferencingFilesByEntityIdAndScopeName(entityId, scopeName);
|
|
416
|
-
for (const filePath of referencingFiles) {
|
|
417
|
-
const file = this.fileToMeta[filePath];
|
|
418
|
-
if (!file || !file.ast) {
|
|
419
|
-
throw new Error(`File not found for element ${filePath}`);
|
|
420
|
-
}
|
|
421
|
-
const imports = extractImportsFromAst(file.ast);
|
|
422
|
-
if (newName in imports) {
|
|
423
|
-
throw new Error(`Cannot rename entity ${oldName} to ${newName} because it has a naming collision with an existing import in file ${filePath}`);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
renameEntity = ({ entityId, oldName, newName, scopeName, }) => {
|
|
428
|
-
this.checkImportInFilesForNewName({
|
|
429
|
-
entityId,
|
|
430
|
-
newName,
|
|
431
|
-
oldName,
|
|
432
|
-
scopeName,
|
|
433
|
-
});
|
|
434
|
-
const { changedFiles, scopeFile } = this.sbScopeManager.renameScopeEntity({
|
|
435
|
-
entityId,
|
|
436
|
-
newName,
|
|
437
|
-
oldName,
|
|
438
|
-
});
|
|
439
|
-
if (changedFiles.length === 0) {
|
|
440
|
-
console.warn("No changed files found for entity", entityId);
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
changedFiles.forEach((file) => {
|
|
444
|
-
this.changedFiles.add(file);
|
|
445
|
-
});
|
|
446
|
-
if (!scopeFile) {
|
|
447
|
-
console.error("Could not find scope file for entity", entityId);
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
this.changedFiles.add(scopeFile);
|
|
451
|
-
// For now, just look in the same folder as the scope file for renames
|
|
452
|
-
// in the future, we may need to look in other folders
|
|
453
|
-
const scopeFolder = path.dirname(scopeFile);
|
|
454
|
-
for (const filePath of Object.keys(this.fileToMeta)) {
|
|
455
|
-
if (filePath.startsWith(scopeFolder) && filePath.endsWith(".tsx")) {
|
|
456
|
-
this.renameIdentifier({
|
|
457
|
-
oldName,
|
|
458
|
-
newName,
|
|
459
|
-
filePath,
|
|
460
|
-
parentBinding: scopeName,
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
}
|
|
288
|
+
addApi = async ({ apiName: _apiName }) => {
|
|
289
|
+
// Return the app-level scope ID
|
|
290
|
+
return getScopeIdFromName("App");
|
|
464
291
|
};
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
this.changedFiles.add(file);
|
|
469
|
-
});
|
|
292
|
+
deleteApi = ({ apiName: _apiName, }) => {
|
|
293
|
+
// Return the app-level scope ID
|
|
294
|
+
return getScopeIdFromName("App");
|
|
470
295
|
};
|
|
471
|
-
addElement = ({ parentElement, tagName, properties, children, id, scopeName, }) => {
|
|
296
|
+
addElement = ({ parentElement, tagName, properties, children, id, scopeName: _scopeName, }) => {
|
|
472
297
|
const logger = getLogger();
|
|
473
298
|
const parentOpeningElementPath = this.getElementToLocation(parentElement.source.id);
|
|
474
299
|
const parentFilepath = this.getElementToFilePath(parentElement.source.id);
|
|
@@ -486,54 +311,6 @@ export class SourceTracker {
|
|
|
486
311
|
throw new Error("Parent element is not a JSX element");
|
|
487
312
|
}
|
|
488
313
|
try {
|
|
489
|
-
const childName = properties.name;
|
|
490
|
-
if (childName && scopeName) {
|
|
491
|
-
const { scopeDefinition, filePath: scopeFilePath } = this.sbScopeManager.getScopeDefinitionAndFilePathByNameOrId({
|
|
492
|
-
identifier: scopeName,
|
|
493
|
-
type: "name",
|
|
494
|
-
});
|
|
495
|
-
if (!scopeDefinition || !scopeFilePath) {
|
|
496
|
-
console.log("No scope creation found for " + scopeName + " will not add a bind");
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
const { name: scopeExportName } = scopeDefinition;
|
|
500
|
-
if (scopeFilePath !== parentFilepath) {
|
|
501
|
-
// check if exportName is already imported into parentFilePath
|
|
502
|
-
const parentFileImports = this.fileToMeta[parentFilepath]?.imports;
|
|
503
|
-
if (!parentFileImports || !parentFileImports[scopeExportName]) {
|
|
504
|
-
const importPath = getImportPath(parentFilepath, scopeFilePath);
|
|
505
|
-
// add the import
|
|
506
|
-
addImport({
|
|
507
|
-
importPath,
|
|
508
|
-
importName: scopeExportName,
|
|
509
|
-
path: parentOpeningElementPath,
|
|
510
|
-
onAdd: () => {
|
|
511
|
-
this.fileToMeta[parentFilepath].imports[scopeExportName] =
|
|
512
|
-
importPath;
|
|
513
|
-
},
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
const childNameValue = childName.value;
|
|
518
|
-
const changedFiles = this.sbScopeManager.addScopeComponent(scopeName, childNameValue);
|
|
519
|
-
changedFiles.forEach((file) => {
|
|
520
|
-
this.changedFiles.add(file);
|
|
521
|
-
});
|
|
522
|
-
// if the scope file path is in the same page directory as this file, then we should destructure it
|
|
523
|
-
if (path.dirname(scopeFilePath) === path.dirname(parentFilepath)) {
|
|
524
|
-
this.sbScopeManager.addScopeDestructuringForComponent({
|
|
525
|
-
elementLocation: parentJSXElementPath,
|
|
526
|
-
scopeName,
|
|
527
|
-
componentFilePath: parentFilepath,
|
|
528
|
-
});
|
|
529
|
-
properties.bind = Property.Expression(`${childNameValue}`);
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
properties.bind = Property.Expression(`${scopeExportName}.${childNameValue}`);
|
|
533
|
-
}
|
|
534
|
-
delete properties.name;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
314
|
const newElement = generateJSXElement({
|
|
538
315
|
id,
|
|
539
316
|
tagName,
|
|
@@ -629,7 +406,7 @@ export class SourceTracker {
|
|
|
629
406
|
throw new Error("Error updating source tracker during add" + e.message);
|
|
630
407
|
}
|
|
631
408
|
};
|
|
632
|
-
deleteElement = ({ source, scopeName, }) => {
|
|
409
|
+
deleteElement = ({ source, scopeName: _scopeName, }) => {
|
|
633
410
|
const logger = getLogger();
|
|
634
411
|
let openingTag = this.getElementToLocation(source.id);
|
|
635
412
|
if (!openingTag) {
|
|
@@ -650,7 +427,7 @@ export class SourceTracker {
|
|
|
650
427
|
logger.error(`Cannot delete a non-JSX element ${source.id}`);
|
|
651
428
|
return;
|
|
652
429
|
}
|
|
653
|
-
const
|
|
430
|
+
const _componentName = getDescriptiveName(openingTag.node);
|
|
654
431
|
const children = [];
|
|
655
432
|
openingTag.traverse({
|
|
656
433
|
JSXElement: (path) => {
|
|
@@ -669,20 +446,8 @@ export class SourceTracker {
|
|
|
669
446
|
}
|
|
670
447
|
delete this.elementToLocation[source.id];
|
|
671
448
|
delete this.elementToFilePath[source.id];
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
changedFiles.forEach((file) => {
|
|
675
|
-
this.changedFiles.add(file);
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
// Then remove all traces of the children
|
|
679
|
-
children.forEach(({ id, name: childComponentName }) => {
|
|
680
|
-
if (childComponentName && scopeName) {
|
|
681
|
-
const changedFiles = this.sbScopeManager.deleteScopeComponent(scopeName, childComponentName);
|
|
682
|
-
changedFiles.forEach((file) => {
|
|
683
|
-
this.changedFiles.add(file);
|
|
684
|
-
});
|
|
685
|
-
}
|
|
449
|
+
// Clean up child element tracking
|
|
450
|
+
children.forEach(({ id }) => {
|
|
686
451
|
delete this.elementToLocation[id];
|
|
687
452
|
delete this.elementToFilePath[id];
|
|
688
453
|
});
|
|
@@ -778,42 +543,6 @@ export class SourceTracker {
|
|
|
778
543
|
}
|
|
779
544
|
return found;
|
|
780
545
|
};
|
|
781
|
-
removeVariableReferencesFromRoot = (functionRoot, variableName) => {
|
|
782
|
-
const referencesToRemove = new Set();
|
|
783
|
-
functionRoot.traverse({
|
|
784
|
-
JSXExpressionContainer(path) {
|
|
785
|
-
const expression = path.get("expression");
|
|
786
|
-
if (expression.isIdentifier() &&
|
|
787
|
-
expression.node.name === variableName) {
|
|
788
|
-
referencesToRemove.add(path);
|
|
789
|
-
}
|
|
790
|
-
else if (expression.isCallExpression()) {
|
|
791
|
-
const callee = expression.get("callee");
|
|
792
|
-
if (callee.isIdentifier() && callee.node.name === variableName) {
|
|
793
|
-
referencesToRemove.add(path);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
},
|
|
797
|
-
Identifier(path) {
|
|
798
|
-
if (path.node.name === variableName && path.isReferencedIdentifier()) {
|
|
799
|
-
const parent = path.parentPath;
|
|
800
|
-
if (parent?.isJSXExpressionContainer()) {
|
|
801
|
-
referencesToRemove.add(parent);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
},
|
|
805
|
-
});
|
|
806
|
-
for (const path of referencesToRemove) {
|
|
807
|
-
try {
|
|
808
|
-
if (!path.removed) {
|
|
809
|
-
path.remove();
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
catch (_e) {
|
|
813
|
-
// Path might already be removed, ignore the error
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
546
|
// If we're deleting the only Column in an Section, remove the Section
|
|
818
547
|
deleteSectionIfOnlyChild = (openingTag) => {
|
|
819
548
|
const parentElement = openingTag.parentPath;
|
|
@@ -935,7 +664,29 @@ export class SourceTracker {
|
|
|
935
664
|
const openingElement = element.get("openingElement");
|
|
936
665
|
if (openingElement.node.selfClosing) {
|
|
937
666
|
openingElement.node.selfClosing = false;
|
|
938
|
-
element.node.closingElement = t.jsxClosingElement(
|
|
667
|
+
element.node.closingElement = t.jsxClosingElement(openingElement.node.name);
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
setJSXChildren = (jsxElement, info) => {
|
|
671
|
+
const logger = getLogger();
|
|
672
|
+
try {
|
|
673
|
+
// Ensure the element is not self-closing
|
|
674
|
+
this.transformSelfClosingTagToRegularTag(jsxElement);
|
|
675
|
+
// Clear existing children
|
|
676
|
+
jsxElement.node.children = [];
|
|
677
|
+
// Handle different types of children content
|
|
678
|
+
if (info.type === "STATIC" && typeof info.value === "string") {
|
|
679
|
+
// For string children, create a text node
|
|
680
|
+
if (info.value.trim() !== "") {
|
|
681
|
+
jsxElement.node.children = [t.jsxText(info.value)];
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
console.warn("setting non-static string children is not supported");
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
catch (e) {
|
|
689
|
+
logger.error("Error setting JSX children", getErrorMeta(e));
|
|
939
690
|
}
|
|
940
691
|
};
|
|
941
692
|
setProperty = ({ source, property, info, }) => {
|
|
@@ -965,8 +716,28 @@ export class SourceTracker {
|
|
|
965
716
|
if (!openingTag.isJSXOpeningElement()) {
|
|
966
717
|
throw new Error(`Element ${source.id} is not a JSXOpeningElement`);
|
|
967
718
|
}
|
|
719
|
+
// Get the JSX element to handle children
|
|
720
|
+
let jsxElement = this.getElementToLocation(source.id);
|
|
721
|
+
if (jsxElement?.isJSXOpeningElement()) {
|
|
722
|
+
jsxElement = jsxElement.parentPath;
|
|
723
|
+
}
|
|
968
724
|
// Iterate over the changes and set each attribute using the helper
|
|
969
725
|
for (const [key, info] of Object.entries(changes)) {
|
|
726
|
+
// Special handling for children property
|
|
727
|
+
if (key === "children") {
|
|
728
|
+
const childrenAttribute = openingTag
|
|
729
|
+
.get("attributes")
|
|
730
|
+
.find((attr) => attr.isJSXAttribute() && attr.node.name.name === "children");
|
|
731
|
+
const jsxChildrenExists = jsxElement.isJSXElement() && jsxElement.node.children.length > 0;
|
|
732
|
+
// We always set the jsx children UNLESS children exists as an attribute and there are no current jsx children
|
|
733
|
+
if (jsxChildrenExists || !childrenAttribute) {
|
|
734
|
+
this.setJSXChildren(jsxElement, info);
|
|
735
|
+
if (childrenAttribute) {
|
|
736
|
+
childrenAttribute.remove();
|
|
737
|
+
}
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
970
741
|
const jsxAttribute = this.setAttribute(openingTag, key, info);
|
|
971
742
|
const imports = getRequiredImportsForProperty(info);
|
|
972
743
|
if (imports.length > 0) {
|
|
@@ -985,13 +756,7 @@ export class SourceTracker {
|
|
|
985
756
|
}
|
|
986
757
|
if (ATTRIBUTE_TYPES_WITH_STATE_ACCESS.includes(info.type) &&
|
|
987
758
|
jsxAttribute) {
|
|
988
|
-
|
|
989
|
-
const scopeImports = this.sbScopeManager.getAndUpdateScopeImportsForCodeSnippet({
|
|
990
|
-
jsxAttribute,
|
|
991
|
-
codeFilePath: fileName,
|
|
992
|
-
elementLocation,
|
|
993
|
-
existingImports: this.fileToMeta[fileName].imports,
|
|
994
|
-
});
|
|
759
|
+
// Add external library imports (but not scope imports)
|
|
995
760
|
for (const externalLibrary of EXTERNAL_LIBRARY_OPTIONS) {
|
|
996
761
|
const referencedGlobalFunctions = getVariableReferences(jsxAttribute, externalLibrary.imports).map((funcName) => {
|
|
997
762
|
return {
|
|
@@ -999,7 +764,7 @@ export class SourceTracker {
|
|
|
999
764
|
importName: funcName,
|
|
1000
765
|
};
|
|
1001
766
|
});
|
|
1002
|
-
|
|
767
|
+
referencedGlobalFunctions.forEach(({ importPath, importName }) => {
|
|
1003
768
|
addImport({
|
|
1004
769
|
importPath,
|
|
1005
770
|
importName,
|
|
@@ -1046,18 +811,12 @@ export class SourceTracker {
|
|
|
1046
811
|
logger.error("Error deleting properties", getErrorMeta(e));
|
|
1047
812
|
}
|
|
1048
813
|
};
|
|
1049
|
-
renameComponent = async ({ widgetSourceId, newName, oldName
|
|
814
|
+
renameComponent = async ({ widgetSourceId, newName, oldName: _oldName, renameInAst = true, }) => {
|
|
1050
815
|
const filePath = this.getElementToFilePath(widgetSourceId);
|
|
1051
816
|
const currentFile = this.fileToMeta[filePath];
|
|
1052
817
|
if (!currentFile || !currentFile.ast) {
|
|
1053
818
|
throw new Error(`File not found for element ${filePath}`);
|
|
1054
819
|
}
|
|
1055
|
-
this.checkImportInFilesForNewName({
|
|
1056
|
-
entityId: widgetSourceId,
|
|
1057
|
-
newName,
|
|
1058
|
-
oldName,
|
|
1059
|
-
scopeName,
|
|
1060
|
-
});
|
|
1061
820
|
let widgetNode = this.getElementToLocation(widgetSourceId);
|
|
1062
821
|
if (!widgetNode) {
|
|
1063
822
|
throw new Error(`Widget ${widgetSourceId} not found`);
|
|
@@ -1065,26 +824,6 @@ export class SourceTracker {
|
|
|
1065
824
|
if (widgetNode?.isJSXElement()) {
|
|
1066
825
|
widgetNode = widgetNode.get("openingElement");
|
|
1067
826
|
}
|
|
1068
|
-
const hasNameAttribute = isNamedComponent(widgetNode.node);
|
|
1069
|
-
if (scopeName) {
|
|
1070
|
-
if (!hasNameAttribute) {
|
|
1071
|
-
// if this is the first component getting named, we might need to add a scope destructuring for it
|
|
1072
|
-
this.sbScopeManager.addScopeDestructuringForComponent({
|
|
1073
|
-
elementLocation: widgetNode,
|
|
1074
|
-
scopeName,
|
|
1075
|
-
componentFilePath: filePath,
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
const changedFiles = this.sbScopeManager.renameScopeComponent({
|
|
1079
|
-
oldName: hasNameAttribute ? oldName : undefined,
|
|
1080
|
-
newName,
|
|
1081
|
-
scopeName,
|
|
1082
|
-
componentFilePath: filePath,
|
|
1083
|
-
});
|
|
1084
|
-
changedFiles.forEach((file) => {
|
|
1085
|
-
this.changedFiles.add(file);
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
827
|
await this.renameManager.renameComponent({
|
|
1089
828
|
widgetNode: widgetNode,
|
|
1090
829
|
newName,
|
|
@@ -1110,41 +849,11 @@ export class SourceTracker {
|
|
|
1110
849
|
});
|
|
1111
850
|
this.changedFiles.add(filePath);
|
|
1112
851
|
};
|
|
1113
|
-
/**
|
|
1114
|
-
* Change the name of a scope definition in a specific file path. Note: if this is part of a page rename,
|
|
1115
|
-
* you have to perform all of the file system operations separately.
|
|
1116
|
-
|
|
1117
|
-
*/
|
|
1118
|
-
renamePage = ({ oldName, newName, scopeFilePath, pageFilePath, }) => {
|
|
1119
|
-
const scopeAst = this.fileToMeta[scopeFilePath]?.ast;
|
|
1120
|
-
if (!scopeAst) {
|
|
1121
|
-
throw new Error(`File not found for element ${scopeFilePath}`);
|
|
1122
|
-
}
|
|
1123
|
-
const pageAst = this.fileToMeta[pageFilePath]?.ast;
|
|
1124
|
-
if (!pageAst) {
|
|
1125
|
-
throw new Error(`File not found for element ${pageFilePath}`);
|
|
1126
|
-
}
|
|
1127
|
-
this.sbScopeManager.renamePageScope({
|
|
1128
|
-
oldName,
|
|
1129
|
-
newName,
|
|
1130
|
-
newFilePath: scopeFilePath,
|
|
1131
|
-
indexAst: pageAst,
|
|
1132
|
-
scopeAst,
|
|
1133
|
-
});
|
|
1134
|
-
this.changedFiles.add(scopeFilePath);
|
|
1135
|
-
this.changedFiles.add(pageFilePath);
|
|
1136
|
-
};
|
|
1137
852
|
getAddElementImports = ({ properties, children, }) => {
|
|
1138
853
|
const componentsManager = ComponentsManager.getInstance();
|
|
1139
854
|
const getPropertyImports = (properties) => {
|
|
1140
855
|
return Object.values(properties)
|
|
1141
856
|
.flatMap((property) => {
|
|
1142
|
-
if (property.type === "EVENT") {
|
|
1143
|
-
return {
|
|
1144
|
-
importPath: "@superblocksteam/library",
|
|
1145
|
-
importName: "EventFlow",
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1148
857
|
if (property.type === "DIMENSION") {
|
|
1149
858
|
return {
|
|
1150
859
|
importPath: "@superblocksteam/library",
|