@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/sb-scope-manager.js
DELETED
|
@@ -1,678 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import * as t from "@babel/types";
|
|
3
|
-
import { getStableEntityId, getStableScopeId, } from "@superblocksteam/library-shared";
|
|
4
|
-
import { sbEntitySymbol } from "@superblocksteam/library-shared/types";
|
|
5
|
-
import { TracedEventEmitter } from "@superblocksteam/shared";
|
|
6
|
-
import { SCOPE_FILE } from "./file-system-helpers.js";
|
|
7
|
-
import { supplementElementIds } from "./parsing/ids.js";
|
|
8
|
-
import { EXTERNAL_LIBRARY_OPTIONS } from "./parsing/imports.js";
|
|
9
|
-
import { getVariableReferences } from "./parsing/jsx.js";
|
|
10
|
-
import { buildScopeDestructuredUsageMap, fromEntityToNode, fromNodeToEntity, updateScopeUsages, addScopeToComponent, isComponentAlreadyUsingScope, parseSbScopeDefinition, updateEntityNode, findBindComponentsInScopeUsage, addTypeParametersToScope, updateDestructuredEntitiesParam, updateScopeNameInOptions, renameScopeVariableDeclaration, updateScopeImports, } from "./parsing/scope.js";
|
|
11
|
-
import { addImport, getImportPath } from "./parsing/util.js";
|
|
12
|
-
import { deleteEntityInAst } from "./refactor/entities.js";
|
|
13
|
-
import { renameEntityInJavascript } from "./refactor/javascript.js";
|
|
14
|
-
export class SbScopeManager extends TracedEventEmitter {
|
|
15
|
-
// maps file name to scope definition
|
|
16
|
-
pageAndAppScopes = new Map();
|
|
17
|
-
scopeIdToFilePath = {};
|
|
18
|
-
sourceTracker;
|
|
19
|
-
filePathsWithDuplicateComponentNames = new Set();
|
|
20
|
-
// this maps scope name to file name to the node where the scope is being spread
|
|
21
|
-
scopeNameToScopeUsage = {};
|
|
22
|
-
constructor(sourceTracker, tracer) {
|
|
23
|
-
super(tracer, { captureRejections: true });
|
|
24
|
-
this.sourceTracker = sourceTracker;
|
|
25
|
-
}
|
|
26
|
-
parseScopes(fileMeta) {
|
|
27
|
-
const scopeFiles = Object.keys(fileMeta).filter((filePath) => filePath.endsWith(SCOPE_FILE));
|
|
28
|
-
const nonScopeFiles = Object.keys(fileMeta).filter((filePath) => !scopeFiles.includes(filePath));
|
|
29
|
-
// get scope defs first
|
|
30
|
-
for (const scopeFile of scopeFiles) {
|
|
31
|
-
if (!fileMeta[scopeFile]) {
|
|
32
|
-
console.error("Scope file not found", scopeFile);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const { ast } = fileMeta[scopeFile];
|
|
36
|
-
if (!ast) {
|
|
37
|
-
console.error("AST not found for scope file", scopeFile);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
const scopeDefinition = parseSbScopeDefinition(ast);
|
|
42
|
-
this.pageAndAppScopes.set(scopeFile, scopeDefinition);
|
|
43
|
-
this.scopeIdToFilePath[scopeDefinition.id] = scopeFile;
|
|
44
|
-
const { idMap } = supplementElementIds({
|
|
45
|
-
fileName: scopeFile,
|
|
46
|
-
ast,
|
|
47
|
-
shouldModifyAst: false,
|
|
48
|
-
scopeId: scopeDefinition.id,
|
|
49
|
-
});
|
|
50
|
-
idMap.forEach((path, id) => {
|
|
51
|
-
this.sourceTracker.setElementToLocation(id, path);
|
|
52
|
-
this.sourceTracker.setElementToFilePath(id, scopeFile);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
console.error("Error parsing scope definition", e);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
// look for scope usages in non-scope files
|
|
60
|
-
for (const nonScopeFile of nonScopeFiles) {
|
|
61
|
-
if (!fileMeta[nonScopeFile])
|
|
62
|
-
return;
|
|
63
|
-
const { ast } = fileMeta[nonScopeFile];
|
|
64
|
-
if (!ast)
|
|
65
|
-
return;
|
|
66
|
-
this.getScopeUsage(ast, nonScopeFile);
|
|
67
|
-
}
|
|
68
|
-
this.reconcileBindPropertiesAndScopeDefinitions();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Resets the scope tracking for a given file path. This function handles two cases:
|
|
72
|
-
* 1. For scope files (ending with SCOPE_FILE):
|
|
73
|
-
* - Removes the existing scope definition
|
|
74
|
-
* - Re-parses the scope definition from the AST
|
|
75
|
-
* - Updates the scope tracking maps with the new definition
|
|
76
|
-
* 2. For non-scope files:
|
|
77
|
-
* - Removes all existing scope usages for the file
|
|
78
|
-
* - Re-parses and adds new scope usages from the AST
|
|
79
|
-
*
|
|
80
|
-
* @param filePath - The path of the file to reset scope tracking for
|
|
81
|
-
*/
|
|
82
|
-
resetScope(filePath) {
|
|
83
|
-
if (filePath.endsWith(SCOPE_FILE)) {
|
|
84
|
-
const scopeDef = this.pageAndAppScopes.get(filePath);
|
|
85
|
-
if (!scopeDef) {
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
this.pageAndAppScopes.delete(filePath);
|
|
89
|
-
const currentFiles = this.sourceTracker.getCurrentFiles();
|
|
90
|
-
const ast = currentFiles[filePath]?.ast;
|
|
91
|
-
if (!ast) {
|
|
92
|
-
console.error("AST not found for scope file", filePath);
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
95
|
-
const scopeDefinition = parseSbScopeDefinition(ast);
|
|
96
|
-
this.pageAndAppScopes.set(filePath, scopeDefinition);
|
|
97
|
-
this.scopeIdToFilePath[scopeDefinition.id] = filePath;
|
|
98
|
-
const { idMap } = supplementElementIds({
|
|
99
|
-
fileName: filePath,
|
|
100
|
-
ast,
|
|
101
|
-
shouldModifyAst: false,
|
|
102
|
-
scopeId: scopeDefinition.id,
|
|
103
|
-
});
|
|
104
|
-
idMap.forEach((path, id) => {
|
|
105
|
-
this.sourceTracker.setElementToLocation(id, path);
|
|
106
|
-
this.sourceTracker.setElementToFilePath(id, filePath);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// remove old scope usages for this file
|
|
111
|
-
for (const scopeName of Object.keys(this.scopeNameToScopeUsage)) {
|
|
112
|
-
if (this.scopeNameToScopeUsage[scopeName]?.[filePath]) {
|
|
113
|
-
delete this.scopeNameToScopeUsage[scopeName][filePath];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// re-add scope usages for this file
|
|
117
|
-
const currentFiles = this.sourceTracker.getCurrentFiles();
|
|
118
|
-
const ast = currentFiles[filePath]?.ast;
|
|
119
|
-
if (!ast) {
|
|
120
|
-
console.error("AST not found for scope file", filePath);
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
this.getScopeUsage(ast, filePath);
|
|
124
|
-
}
|
|
125
|
-
return this.reconcileBindPropertiesAndScopeDefinitions();
|
|
126
|
-
}
|
|
127
|
-
getScopeDefinitionAndFilePathByNameOrId({ identifier, type, }) {
|
|
128
|
-
for (const [filePath, scopeDef] of this.pageAndAppScopes.entries()) {
|
|
129
|
-
if (type === "id" && scopeDef.id === identifier) {
|
|
130
|
-
return { scopeDefinition: scopeDef, filePath };
|
|
131
|
-
}
|
|
132
|
-
if (type === "name" && scopeDef.name === identifier) {
|
|
133
|
-
return { scopeDefinition: scopeDef, filePath };
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return { scopeDefinition: undefined, filePath: undefined };
|
|
137
|
-
}
|
|
138
|
-
addScopeDestructuringForComponent({ elementLocation, scopeName, componentFilePath, }) {
|
|
139
|
-
if (isComponentAlreadyUsingScope(elementLocation, this.scopeNameToScopeUsage?.[scopeName]?.[componentFilePath])) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
// Find the scope definition
|
|
143
|
-
const { scopeDefinition: scopeDef } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
144
|
-
identifier: scopeName,
|
|
145
|
-
type: "name",
|
|
146
|
-
});
|
|
147
|
-
if (!scopeDef) {
|
|
148
|
-
this.emit("scopeNotFound", scopeName);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
// Add scope to the component
|
|
152
|
-
const addedNodePath = addScopeToComponent({
|
|
153
|
-
elementLocation,
|
|
154
|
-
scopeDefinition: scopeDef,
|
|
155
|
-
});
|
|
156
|
-
// Update the scope usage map
|
|
157
|
-
if (addedNodePath) {
|
|
158
|
-
if (!this.scopeNameToScopeUsage[scopeName]) {
|
|
159
|
-
this.scopeNameToScopeUsage[scopeName] = {};
|
|
160
|
-
}
|
|
161
|
-
if (!this.scopeNameToScopeUsage[scopeName][componentFilePath]) {
|
|
162
|
-
this.scopeNameToScopeUsage[scopeName][componentFilePath] = [];
|
|
163
|
-
}
|
|
164
|
-
this.scopeNameToScopeUsage[scopeName][componentFilePath].push(addedNodePath);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
getDefaultScopeDefForFile(filePath) {
|
|
168
|
-
const scopeFilePath = path.join(path.dirname(filePath), SCOPE_FILE);
|
|
169
|
-
return this.pageAndAppScopes.get(scopeFilePath);
|
|
170
|
-
}
|
|
171
|
-
getAndUpdateScopeImportsForCodeSnippet({ jsxAttribute, codeFilePath, existingImports, elementLocation, }) {
|
|
172
|
-
const defaultScopeDef = this.getDefaultScopeDefForFile(codeFilePath);
|
|
173
|
-
// We are searching for all references of different global scope or entities inside the default scope
|
|
174
|
-
// For example for an element in Page1, we want to search for "App", "PageEntity1", "PageEntity2", ..etc
|
|
175
|
-
const unimportedScopes = this.findUnimportedScopes(existingImports);
|
|
176
|
-
const referencesToSearch = new Set([
|
|
177
|
-
...unimportedScopes,
|
|
178
|
-
...(defaultScopeDef?.entityNames ?? []),
|
|
179
|
-
]);
|
|
180
|
-
const usedReferences = getVariableReferences(jsxAttribute, referencesToSearch);
|
|
181
|
-
const usedScopes = usedReferences.filter((reference) => unimportedScopes.has(reference));
|
|
182
|
-
// if there are any references of default scope variables, make sure
|
|
183
|
-
// to import the default scope and update all
|
|
184
|
-
if (usedScopes.length !== referencesToSearch.size && defaultScopeDef) {
|
|
185
|
-
usedScopes.push(defaultScopeDef.name);
|
|
186
|
-
this.addScopeDestructuringForComponent({
|
|
187
|
-
elementLocation,
|
|
188
|
-
scopeName: defaultScopeDef.name,
|
|
189
|
-
componentFilePath: codeFilePath,
|
|
190
|
-
});
|
|
191
|
-
this.updateScopeUsages(defaultScopeDef.name, defaultScopeDef.entityNames);
|
|
192
|
-
}
|
|
193
|
-
const result = usedScopes
|
|
194
|
-
.map((scopeName) => {
|
|
195
|
-
const { scopeDefinition: scopeDef, filePath } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
196
|
-
identifier: scopeName,
|
|
197
|
-
type: "name",
|
|
198
|
-
});
|
|
199
|
-
if (!scopeDef || !filePath) {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
const importPath = getImportPath(codeFilePath, filePath);
|
|
203
|
-
return {
|
|
204
|
-
importPath,
|
|
205
|
-
importName: scopeDef.name,
|
|
206
|
-
};
|
|
207
|
-
})
|
|
208
|
-
.filter((item) => item !== null);
|
|
209
|
-
return result;
|
|
210
|
-
}
|
|
211
|
-
findUnimportedScopes(existingImports) {
|
|
212
|
-
const unimportedScopes = new Set();
|
|
213
|
-
const allScopeNames = Array.from(this.pageAndAppScopes.values()).map((scope) => scope.name);
|
|
214
|
-
for (const scopeName of allScopeNames) {
|
|
215
|
-
if (existingImports?.[scopeName]) {
|
|
216
|
-
// already imported in this file, dont need to import
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
unimportedScopes.add(scopeName);
|
|
220
|
-
}
|
|
221
|
-
return unimportedScopes;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Manage page scope
|
|
225
|
-
*/
|
|
226
|
-
/**
|
|
227
|
-
* Rename a page and update the scope definition, ensure that the new scope file
|
|
228
|
-
* has been written to the file system and parsed before calling this function.
|
|
229
|
-
*/
|
|
230
|
-
renamePageScope({ oldName, newName, newFilePath, indexAst, scopeAst, }) {
|
|
231
|
-
const scopeDef = this.pageAndAppScopes.get(newFilePath);
|
|
232
|
-
if (!scopeDef) {
|
|
233
|
-
throw new Error(`Scope definition not found for file ${newFilePath}`);
|
|
234
|
-
}
|
|
235
|
-
updateScopeNameInOptions(scopeDef, newName);
|
|
236
|
-
scopeDef.id = getStableScopeId(newName);
|
|
237
|
-
scopeDef.name = newName;
|
|
238
|
-
renameScopeVariableDeclaration(oldName, newName, scopeAst);
|
|
239
|
-
updateScopeImports(oldName, newName, indexAst);
|
|
240
|
-
const oldScopeDef = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
241
|
-
identifier: oldName,
|
|
242
|
-
type: "name",
|
|
243
|
-
});
|
|
244
|
-
if (oldScopeDef.filePath) {
|
|
245
|
-
this.deleteScope(oldScopeDef.filePath);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
Manage scope entities
|
|
250
|
-
*/
|
|
251
|
-
addScopeEntity(scopeId, payload) {
|
|
252
|
-
// Find the scope definition
|
|
253
|
-
const { scopeDefinition: scopeDef, filePath } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
254
|
-
identifier: scopeId,
|
|
255
|
-
type: "id",
|
|
256
|
-
});
|
|
257
|
-
if (!scopeDef) {
|
|
258
|
-
console.warn("Scope definition not found for scopeId", scopeId);
|
|
259
|
-
this.emit("scopeNotFound", scopeId);
|
|
260
|
-
return [];
|
|
261
|
-
}
|
|
262
|
-
const { entity: entityAst, imports } = fromEntityToNode({
|
|
263
|
-
[sbEntitySymbol]: true,
|
|
264
|
-
type: payload.type,
|
|
265
|
-
name: payload.name,
|
|
266
|
-
...payload.attributes,
|
|
267
|
-
});
|
|
268
|
-
// Use the existing scopeObject path
|
|
269
|
-
const objPath = scopeDef.scopeEntities;
|
|
270
|
-
if (!objPath || !objPath.isObjectExpression()) {
|
|
271
|
-
console.warn("Scope object path not found for scopeId", scopeId);
|
|
272
|
-
this.emit("scopeNotFound", scopeId);
|
|
273
|
-
return [];
|
|
274
|
-
}
|
|
275
|
-
// Add the entity to the object expression
|
|
276
|
-
const [newEntityNode] = objPath.pushContainer("properties", entityAst);
|
|
277
|
-
// Add all required imports
|
|
278
|
-
imports.forEach(({ importName, importPath }) => {
|
|
279
|
-
addImport({
|
|
280
|
-
path: objPath,
|
|
281
|
-
importName,
|
|
282
|
-
importPath,
|
|
283
|
-
onAdd: () => {
|
|
284
|
-
// todo: we could track this in the fileToMeta map
|
|
285
|
-
},
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
const id = getStableEntityId(scopeId, payload.name);
|
|
289
|
-
this.sourceTracker.setElementToLocation(id, newEntityNode);
|
|
290
|
-
this.sourceTracker.setElementToFilePath(id, filePath);
|
|
291
|
-
scopeDef.entityNames.push(payload.name);
|
|
292
|
-
scopeDef.scopeNameToEntityId[payload.name] = id;
|
|
293
|
-
const updatedFiles = this.updateScopeUsages(scopeDef.name, scopeDef.entityNames);
|
|
294
|
-
updateDestructuredEntitiesParam(scopeDef);
|
|
295
|
-
return [...updatedFiles, filePath];
|
|
296
|
-
}
|
|
297
|
-
updateScopeEntity({ entityId, updates }) {
|
|
298
|
-
const entityNode = this.sourceTracker.getElementToLocation(entityId);
|
|
299
|
-
const codeFilePath = this.sourceTracker.getElementToFilePath(entityId);
|
|
300
|
-
if (!entityNode || !t.isObjectProperty(entityNode.node)) {
|
|
301
|
-
throw new Error("Entity to update not found " + entityId);
|
|
302
|
-
}
|
|
303
|
-
if (!codeFilePath) {
|
|
304
|
-
throw new Error("File path not found for entity: " + entityId);
|
|
305
|
-
}
|
|
306
|
-
const scopeDef = this.pageAndAppScopes.get(codeFilePath);
|
|
307
|
-
if (!scopeDef) {
|
|
308
|
-
throw new Error("Scope definition not found for file: " + codeFilePath);
|
|
309
|
-
}
|
|
310
|
-
const newEntity = fromNodeToEntity(entityNode, entityId);
|
|
311
|
-
if (!newEntity) {
|
|
312
|
-
throw new Error("Entity could not be created from node: " + entityId);
|
|
313
|
-
}
|
|
314
|
-
const { imports } = updateEntityNode(entityNode, updates ?? {}, entityId);
|
|
315
|
-
// looke for scope & external imports
|
|
316
|
-
const existingImports = this.sourceTracker.getCurrentFiles()[codeFilePath].imports;
|
|
317
|
-
const unimportedScopes = this.findUnimportedScopes(existingImports);
|
|
318
|
-
const scopeReferences = getVariableReferences(entityNode.node, unimportedScopes);
|
|
319
|
-
const scopeImports = scopeReferences
|
|
320
|
-
.map((scopeName) => {
|
|
321
|
-
const { scopeDefinition: scopeDef, filePath } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
322
|
-
identifier: scopeName,
|
|
323
|
-
type: "name",
|
|
324
|
-
});
|
|
325
|
-
if (!scopeDef || !filePath) {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
const importPath = getImportPath(codeFilePath, filePath);
|
|
329
|
-
return {
|
|
330
|
-
importPath,
|
|
331
|
-
importName: scopeDef.name,
|
|
332
|
-
};
|
|
333
|
-
})
|
|
334
|
-
.filter((item) => item !== null);
|
|
335
|
-
let allImports = [...imports, ...scopeImports];
|
|
336
|
-
for (const externalLibrary of EXTERNAL_LIBRARY_OPTIONS) {
|
|
337
|
-
const referencedGlobalFunctions = getVariableReferences(entityNode.node, externalLibrary.imports).map((funcName) => {
|
|
338
|
-
return {
|
|
339
|
-
importPath: externalLibrary.library,
|
|
340
|
-
importName: funcName,
|
|
341
|
-
};
|
|
342
|
-
});
|
|
343
|
-
allImports = [...allImports, ...referencedGlobalFunctions];
|
|
344
|
-
}
|
|
345
|
-
allImports.forEach(({ importName, importPath }) => {
|
|
346
|
-
addImport({
|
|
347
|
-
importPath,
|
|
348
|
-
importName,
|
|
349
|
-
path: entityNode.parentPath,
|
|
350
|
-
onAdd: () => { },
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
return codeFilePath;
|
|
354
|
-
}
|
|
355
|
-
deleteScopeEntity(entityId) {
|
|
356
|
-
const entityNode = this.sourceTracker.getElementToLocation(entityId);
|
|
357
|
-
if (!entityNode) {
|
|
358
|
-
console.warn("Entity to delete not found", entityId);
|
|
359
|
-
this.emit("entityNotFound", entityId, "deleteScopeEntity");
|
|
360
|
-
return {
|
|
361
|
-
changedFiles: [],
|
|
362
|
-
deletedEntitiesNames: [],
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
const entityName = (entityNode?.node?.key).name;
|
|
366
|
-
const filePath = this.sourceTracker.getElementToFilePath(entityId);
|
|
367
|
-
if (!entityNode || !t.isObjectProperty(entityNode.node)) {
|
|
368
|
-
throw new Error("Entity to delete not found" + entityId);
|
|
369
|
-
}
|
|
370
|
-
if (!filePath) {
|
|
371
|
-
throw new Error("File path not found for entity: " + entityId);
|
|
372
|
-
}
|
|
373
|
-
const scopeDef = this.pageAndAppScopes.get(filePath);
|
|
374
|
-
if (!scopeDef) {
|
|
375
|
-
throw new Error("Scope definition not found for file: " + filePath);
|
|
376
|
-
}
|
|
377
|
-
entityNode.remove();
|
|
378
|
-
this.sourceTracker.deleteElementToLocation(entityId);
|
|
379
|
-
this.sourceTracker.deleteElementToFilePath(entityId);
|
|
380
|
-
scopeDef.entityNames = scopeDef.entityNames.filter((name) => name !== entityName);
|
|
381
|
-
delete scopeDef.scopeNameToEntityId[entityName];
|
|
382
|
-
const updatedFiles = this.updateScopeUsages(scopeDef.name, scopeDef.entityNames);
|
|
383
|
-
updatedFiles.forEach((file) => {
|
|
384
|
-
const fileMeta = this.sourceTracker.getCurrentFiles()[file];
|
|
385
|
-
if (fileMeta && fileMeta.ast) {
|
|
386
|
-
deleteEntityInAst({
|
|
387
|
-
entityName,
|
|
388
|
-
ast: fileMeta.ast,
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
updateDestructuredEntitiesParam(scopeDef);
|
|
393
|
-
return {
|
|
394
|
-
changedFiles: [...updatedFiles, filePath],
|
|
395
|
-
deletedEntitiesNames: [entityName],
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
getReferencingFilesByScopeName(scopeName) {
|
|
399
|
-
const referencingFiles = new Set();
|
|
400
|
-
if (scopeName && this.scopeNameToScopeUsage[scopeName]) {
|
|
401
|
-
Object.keys(this.scopeNameToScopeUsage[scopeName]).forEach((filePath) => {
|
|
402
|
-
referencingFiles.add(filePath);
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
return referencingFiles;
|
|
406
|
-
}
|
|
407
|
-
getReferencingFilesByEntityId(entityId) {
|
|
408
|
-
let referencingFiles = new Set();
|
|
409
|
-
const filePath = this.sourceTracker.getElementToFilePath(entityId);
|
|
410
|
-
if (filePath) {
|
|
411
|
-
referencingFiles.add(filePath);
|
|
412
|
-
const scopeDef = this.pageAndAppScopes.get(filePath);
|
|
413
|
-
if (scopeDef) {
|
|
414
|
-
const scopeName = scopeDef.name;
|
|
415
|
-
referencingFiles = new Set([
|
|
416
|
-
...referencingFiles,
|
|
417
|
-
...this.getReferencingFilesByScopeName(scopeName),
|
|
418
|
-
]);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return referencingFiles;
|
|
422
|
-
}
|
|
423
|
-
getReferencingFilesByEntityIdAndScopeName(entityId, scopeName) {
|
|
424
|
-
return new Set([
|
|
425
|
-
...this.getReferencingFilesByEntityId(entityId),
|
|
426
|
-
...this.getReferencingFilesByScopeName(scopeName),
|
|
427
|
-
]);
|
|
428
|
-
}
|
|
429
|
-
renameScopeEntity({ entityId, newName, oldName, }) {
|
|
430
|
-
const filePath = this.sourceTracker.getElementToFilePath(entityId);
|
|
431
|
-
if (!filePath) {
|
|
432
|
-
return {
|
|
433
|
-
changedFiles: [],
|
|
434
|
-
scopeFile: filePath,
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
const scopeDef = this.pageAndAppScopes.get(filePath);
|
|
438
|
-
if (!scopeDef) {
|
|
439
|
-
return {
|
|
440
|
-
changedFiles: [],
|
|
441
|
-
scopeFile: filePath,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
const entityNode = this.sourceTracker.getElementToLocation(entityId);
|
|
445
|
-
if (!entityNode || !t.isObjectProperty(entityNode.node)) {
|
|
446
|
-
return {
|
|
447
|
-
changedFiles: [],
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
const key = entityNode.get("key");
|
|
451
|
-
if (key) {
|
|
452
|
-
key.replaceWith(t.identifier(newName));
|
|
453
|
-
}
|
|
454
|
-
// Update references in all values in the scope file
|
|
455
|
-
const scopeEntities = scopeDef.scopeEntities;
|
|
456
|
-
if (scopeEntities) {
|
|
457
|
-
renameEntityInJavascript({
|
|
458
|
-
oldName,
|
|
459
|
-
newName,
|
|
460
|
-
nodePath: scopeEntities,
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
scopeDef.entityNames = scopeDef.entityNames.map((name) => name === oldName ? newName : name);
|
|
464
|
-
// clear references to old name and set references to new name
|
|
465
|
-
const newEntityId = getStableEntityId(scopeDef.id, newName);
|
|
466
|
-
this.sourceTracker.deleteElementToLocation(entityId);
|
|
467
|
-
this.sourceTracker.deleteElementToFilePath(entityId);
|
|
468
|
-
scopeDef.scopeNameToEntityId[newName] = newEntityId;
|
|
469
|
-
this.sourceTracker.setElementToLocation(newEntityId, entityNode);
|
|
470
|
-
this.sourceTracker.setElementToFilePath(newEntityId, filePath);
|
|
471
|
-
delete scopeDef.scopeNameToEntityId[oldName];
|
|
472
|
-
const updatedFiles = this.updateScopeUsages(scopeDef.name, scopeDef.entityNames);
|
|
473
|
-
updateDestructuredEntitiesParam(scopeDef);
|
|
474
|
-
return {
|
|
475
|
-
changedFiles: [...updatedFiles, filePath],
|
|
476
|
-
scopeFile: filePath,
|
|
477
|
-
};
|
|
478
|
-
}
|
|
479
|
-
/*
|
|
480
|
-
Manage scope component types
|
|
481
|
-
*/
|
|
482
|
-
addScopeComponent(scopeName, componentName) {
|
|
483
|
-
const { scopeDefinition: currentScope, filePath } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
484
|
-
identifier: scopeName,
|
|
485
|
-
type: "name",
|
|
486
|
-
});
|
|
487
|
-
if (!currentScope) {
|
|
488
|
-
this.emit("scopeNotFound", scopeName);
|
|
489
|
-
return [];
|
|
490
|
-
}
|
|
491
|
-
const scopeDef = currentScope.scopeComponents
|
|
492
|
-
? currentScope
|
|
493
|
-
: addTypeParametersToScope(currentScope);
|
|
494
|
-
if (!scopeDef.scopeComponents) {
|
|
495
|
-
throw new Error("Scope components not found, even though we added type parameters");
|
|
496
|
-
}
|
|
497
|
-
const newProperty = t.tsPropertySignature(t.identifier(componentName), t.tsTypeAnnotation(t.tsAnyKeyword()));
|
|
498
|
-
const newComponents = scopeDef.scopeComponents.pushContainer("members", newProperty);
|
|
499
|
-
// Update the entity names list
|
|
500
|
-
scopeDef.entityNames.push(componentName);
|
|
501
|
-
// Update all scope usages to include the new component
|
|
502
|
-
const updatedFiles = this.updateScopeUsages(scopeDef.name, scopeDef.entityNames);
|
|
503
|
-
const entityId = getStableEntityId(scopeDef.id, componentName);
|
|
504
|
-
this.sourceTracker.setElementToLocation(entityId, newComponents[0]);
|
|
505
|
-
this.sourceTracker.setElementToFilePath(entityId, filePath);
|
|
506
|
-
updateDestructuredEntitiesParam(scopeDef);
|
|
507
|
-
return [...updatedFiles, filePath];
|
|
508
|
-
}
|
|
509
|
-
deleteScopeComponent(scopeName, componentName) {
|
|
510
|
-
const { scopeDefinition: scopeDef } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
511
|
-
identifier: scopeName,
|
|
512
|
-
type: "name",
|
|
513
|
-
});
|
|
514
|
-
if (!scopeDef) {
|
|
515
|
-
return [];
|
|
516
|
-
}
|
|
517
|
-
const componentTypeId = getStableEntityId(scopeDef.id, componentName);
|
|
518
|
-
const componentNode = this.sourceTracker.getElementToLocation(componentTypeId);
|
|
519
|
-
const filePath = this.sourceTracker.getElementToFilePath(componentTypeId);
|
|
520
|
-
if (!componentNode ||
|
|
521
|
-
!t.isTSPropertySignature(componentNode.node) ||
|
|
522
|
-
!filePath) {
|
|
523
|
-
return [];
|
|
524
|
-
}
|
|
525
|
-
// Remove the component node from the AST
|
|
526
|
-
componentNode.remove();
|
|
527
|
-
// Clean up references
|
|
528
|
-
this.sourceTracker.deleteElementToLocation(componentTypeId);
|
|
529
|
-
this.sourceTracker.deleteElementToFilePath(componentTypeId);
|
|
530
|
-
// Update the entity names list
|
|
531
|
-
scopeDef.entityNames = scopeDef.entityNames.filter((name) => name !== componentName);
|
|
532
|
-
delete scopeDef.scopeNameToEntityId[componentName];
|
|
533
|
-
const updatedFiles = this.updateScopeUsages(scopeDef.name, scopeDef.entityNames);
|
|
534
|
-
updatedFiles.forEach((file) => {
|
|
535
|
-
const fileMeta = this.sourceTracker.getCurrentFiles()[file];
|
|
536
|
-
if (fileMeta && fileMeta.ast) {
|
|
537
|
-
deleteEntityInAst({
|
|
538
|
-
entityName: componentName,
|
|
539
|
-
ast: fileMeta.ast,
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
updateDestructuredEntitiesParam(scopeDef);
|
|
544
|
-
return [...updatedFiles, filePath];
|
|
545
|
-
}
|
|
546
|
-
getReferencingFiles(scopeName) {
|
|
547
|
-
const referencingFiles = new Set();
|
|
548
|
-
if (scopeName && this.scopeNameToScopeUsage[scopeName]) {
|
|
549
|
-
Object.keys(this.scopeNameToScopeUsage[scopeName]).forEach((filePath) => {
|
|
550
|
-
referencingFiles.add(filePath);
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
return referencingFiles;
|
|
554
|
-
}
|
|
555
|
-
getScopeFileByScopeName(scopeName) {
|
|
556
|
-
const { filePath: scopeFile } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
557
|
-
identifier: scopeName,
|
|
558
|
-
type: "name",
|
|
559
|
-
});
|
|
560
|
-
return scopeFile;
|
|
561
|
-
}
|
|
562
|
-
renameScopeComponent({ newName, oldName, scopeName, componentFilePath, }) {
|
|
563
|
-
if (!oldName) {
|
|
564
|
-
return this.addScopeComponent(scopeName, newName);
|
|
565
|
-
}
|
|
566
|
-
const { scopeDefinition: scopeDef, filePath: scopeFile } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
567
|
-
identifier: scopeName,
|
|
568
|
-
type: "name",
|
|
569
|
-
});
|
|
570
|
-
if (!scopeDef) {
|
|
571
|
-
return [];
|
|
572
|
-
}
|
|
573
|
-
const componentTypeId = getStableEntityId(scopeDef.id, oldName);
|
|
574
|
-
const filePath = this.sourceTracker.getElementToFilePath(componentTypeId);
|
|
575
|
-
if (!filePath) {
|
|
576
|
-
// this could happen if we're renaming a component that had a duplicate name with somthing else
|
|
577
|
-
return this.resetScope(scopeFile);
|
|
578
|
-
}
|
|
579
|
-
const componentNode = this.sourceTracker.getElementToLocation(componentTypeId);
|
|
580
|
-
if (!componentNode) {
|
|
581
|
-
// this could happen if we're renaming a component that had a duplicate name with somthing else
|
|
582
|
-
return this.resetScope(scopeFile);
|
|
583
|
-
}
|
|
584
|
-
// Update the key name in the AST
|
|
585
|
-
const key = componentNode.get("key");
|
|
586
|
-
if (key) {
|
|
587
|
-
key.replaceWith(t.identifier(newName));
|
|
588
|
-
}
|
|
589
|
-
// Update references in all values in the scope file
|
|
590
|
-
const scopeEntities = scopeDef.scopeEntities;
|
|
591
|
-
if (scopeEntities) {
|
|
592
|
-
renameEntityInJavascript({
|
|
593
|
-
oldName,
|
|
594
|
-
newName,
|
|
595
|
-
nodePath: scopeEntities,
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
// Update the entity names list
|
|
599
|
-
scopeDef.entityNames = scopeDef.entityNames.map((name) => name === oldName ? newName : name);
|
|
600
|
-
delete scopeDef.scopeNameToEntityId[oldName];
|
|
601
|
-
const updatedFiles = this.updateScopeUsages(scopeDef.name, scopeDef.entityNames);
|
|
602
|
-
// clear references to old name and set references to new name
|
|
603
|
-
this.sourceTracker.deleteElementToLocation(componentTypeId);
|
|
604
|
-
this.sourceTracker.deleteElementToFilePath(componentTypeId);
|
|
605
|
-
const newComponentTypeId = getStableEntityId(scopeDef.id, newName);
|
|
606
|
-
scopeDef.scopeNameToEntityId[newName] = newComponentTypeId;
|
|
607
|
-
this.sourceTracker.setElementToLocation(newComponentTypeId, componentNode);
|
|
608
|
-
this.sourceTracker.setElementToFilePath(newComponentTypeId, filePath);
|
|
609
|
-
updateDestructuredEntitiesParam(scopeDef);
|
|
610
|
-
// handle edge case with a user fixing duplicate names
|
|
611
|
-
if (this.filePathsWithDuplicateComponentNames.has(componentFilePath)) {
|
|
612
|
-
const reconciledFiles = this.reconcileBindPropertiesAndScopeDefinitions();
|
|
613
|
-
return [...updatedFiles, ...reconciledFiles, filePath];
|
|
614
|
-
}
|
|
615
|
-
return [...updatedFiles, filePath];
|
|
616
|
-
}
|
|
617
|
-
getScopeUsage(ast, filePath) {
|
|
618
|
-
const allScopeNames = new Set();
|
|
619
|
-
for (const [_, scopeDef] of this.pageAndAppScopes.entries()) {
|
|
620
|
-
allScopeNames.add(scopeDef.name);
|
|
621
|
-
}
|
|
622
|
-
buildScopeDestructuredUsageMap(ast, filePath, allScopeNames, this.scopeNameToScopeUsage);
|
|
623
|
-
}
|
|
624
|
-
reconcileBindPropertiesAndScopeDefinitions() {
|
|
625
|
-
this.filePathsWithDuplicateComponentNames.clear();
|
|
626
|
-
for (const [scopeName, scopeUsages] of Object.entries(this.scopeNameToScopeUsage)) {
|
|
627
|
-
const { scopeDefinition: scopeDef } = this.getScopeDefinitionAndFilePathByNameOrId({
|
|
628
|
-
identifier: scopeName,
|
|
629
|
-
type: "name",
|
|
630
|
-
});
|
|
631
|
-
if (!scopeDef) {
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
const missingComponents = new Set();
|
|
635
|
-
const seenNames = new Set();
|
|
636
|
-
for (const [filePath, usages] of Object.entries(scopeUsages)) {
|
|
637
|
-
for (const usage of usages) {
|
|
638
|
-
const bindNames = findBindComponentsInScopeUsage(usage);
|
|
639
|
-
for (const bindName of bindNames) {
|
|
640
|
-
if (seenNames.has(bindName)) {
|
|
641
|
-
this.filePathsWithDuplicateComponentNames.add(filePath);
|
|
642
|
-
}
|
|
643
|
-
seenNames.add(bindName);
|
|
644
|
-
if (!scopeDef.entityNames.includes(bindName)) {
|
|
645
|
-
missingComponents.add(bindName);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
const updatedFiles = [];
|
|
651
|
-
// Add missing components to the scope definition
|
|
652
|
-
for (const missingComponent of missingComponents) {
|
|
653
|
-
updatedFiles.push(...this.addScopeComponent(scopeName, missingComponent));
|
|
654
|
-
}
|
|
655
|
-
return updatedFiles;
|
|
656
|
-
}
|
|
657
|
-
return [];
|
|
658
|
-
}
|
|
659
|
-
updateScopeUsages(scopeName, entityNames) {
|
|
660
|
-
const uniqueEntityNames = [...new Set(entityNames)];
|
|
661
|
-
const scopeUsages = this.scopeNameToScopeUsage[scopeName];
|
|
662
|
-
if (scopeUsages) {
|
|
663
|
-
updateScopeUsages(scopeUsages, uniqueEntityNames);
|
|
664
|
-
return Object.keys(scopeUsages);
|
|
665
|
-
}
|
|
666
|
-
return [];
|
|
667
|
-
}
|
|
668
|
-
deleteScope(scopeName) {
|
|
669
|
-
const scopeDef = this.pageAndAppScopes.get(scopeName);
|
|
670
|
-
if (!scopeDef) {
|
|
671
|
-
return [];
|
|
672
|
-
}
|
|
673
|
-
this.pageAndAppScopes.delete(scopeName);
|
|
674
|
-
delete this.scopeIdToFilePath[scopeDef.id];
|
|
675
|
-
delete this.scopeNameToScopeUsage[scopeName];
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
//# sourceMappingURL=sb-scope-manager.js.map
|