@superblocksteam/vite-plugin-file-sync 2.0.55 → 2.0.56-next.1
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 +140 -361
- 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 +8 -33
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +217 -600
- 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 +84 -375
- 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
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import fs from "fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import * as t from "@babel/types";
|
|
4
|
-
import {
|
|
4
|
+
import { PROCESSED_TRANSACTIONS_ATTRIBUTE, ROOT_WIDGET_ATTRIBUTE, SOURCE_ID_ATTRIBUTE, WIDGET_DISABLE_DND, } from "@superblocksteam/library-shared";
|
|
5
5
|
import { addTracingToMethods, TracedEventEmitter, } from "@superblocksteam/shared";
|
|
6
6
|
import { readAppApiYamlFile, writeApiFiles, } from "@superblocksteam/util";
|
|
7
7
|
import { glob } from "glob";
|
|
8
|
-
import { isEqual } from "lodash-es";
|
|
8
|
+
import { isEqual, debounce } from "lodash-es";
|
|
9
9
|
import yaml from "yaml";
|
|
10
10
|
import { generateJSXAttribute } from "./codegen.js";
|
|
11
11
|
import { ComponentsManager } from "./components-manager.js";
|
|
12
12
|
import { addLegacyCustomComponentVariables, modifyLegacyCustomComponentElements, modifyLegacyCustomComponentImports, } from "./custom-components.js";
|
|
13
13
|
import { applyErrorHandling, } from "./errors/error-handler.js";
|
|
14
|
-
import { getApiFilePath,
|
|
14
|
+
import { getApiFilePath, isPageFilePath, PAGES_DIRECTORY, SCOPE_FILE, } from "./file-system-helpers.js";
|
|
15
15
|
import { generate } from "./generate.js";
|
|
16
|
-
import { OperationProcessor } from "./operations/operation-processor.js";
|
|
17
16
|
import { doesNodePathHaveBinding } from "./parsing/bindings.js";
|
|
18
17
|
import { getSbElementId } from "./parsing/ids.js";
|
|
19
18
|
import { makeJSXAttribute } from "./parsing/jsx.js";
|
|
20
19
|
import { getRootNodes } from "./parsing/page.js";
|
|
21
|
-
import { getScope } from "./parsing/scope.js";
|
|
22
20
|
import { getLegacyComponentsFolder, isCustomBuildEnabled, } from "./plugin-options.js";
|
|
23
21
|
import { RenameManager } from "./rename-manager.js";
|
|
24
22
|
import { getFullImportPath } from "./resolver.js";
|
|
23
|
+
import { findRouterFile } from "./router-parser.js";
|
|
25
24
|
import { SourceTracker } from "./source-tracker.js";
|
|
26
25
|
import { traverse } from "./traverse.js";
|
|
27
26
|
import { getErrorMeta, getLogger } from "./util/logger.js";
|
|
28
|
-
import {
|
|
27
|
+
import { getScopeIdFromName, getScopeNameFromPath } from "./util.js";
|
|
29
28
|
const SUPPORTED_FILETYPES = [
|
|
29
|
+
{
|
|
30
|
+
type: "ts",
|
|
31
|
+
extension: ".ts",
|
|
32
|
+
},
|
|
30
33
|
{
|
|
31
34
|
type: "tsx",
|
|
32
35
|
extension: ".tsx",
|
|
@@ -58,11 +61,10 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
58
61
|
apiFiles = {};
|
|
59
62
|
sourceTracker;
|
|
60
63
|
fsOperationQueue;
|
|
61
|
-
operationProcessor;
|
|
62
64
|
generationNumberSequence;
|
|
63
|
-
routes = {};
|
|
64
65
|
routeChangesQueue = [];
|
|
65
66
|
pageAdditionQueue = new Set();
|
|
67
|
+
routerFilePath = null;
|
|
66
68
|
watcher;
|
|
67
69
|
registeredComponentPaths = {};
|
|
68
70
|
renameManager = new RenameManager();
|
|
@@ -70,21 +72,15 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
70
72
|
transactionNonce = Date.now();
|
|
71
73
|
pendingTransactions = new Set();
|
|
72
74
|
processedTransactions = [];
|
|
75
|
+
debouncedFileUpdateHandlers = new Map();
|
|
73
76
|
constructor(fsOperationQueue, generationNumberSequence, tracer) {
|
|
74
77
|
super(tracer, { captureRejections: true });
|
|
75
78
|
this.rootDir = "/";
|
|
76
79
|
this.fsOperationQueue = fsOperationQueue;
|
|
77
80
|
this.generationNumberSequence = generationNumberSequence;
|
|
78
81
|
this._tracer = tracer;
|
|
79
|
-
// intentionally a new queue here, we don't want to share the queue with the fsOperationQueue
|
|
80
|
-
this.operationProcessor = new OperationProcessor({
|
|
81
|
-
batchWindowMs: 50,
|
|
82
|
-
maxBatchSize: 100,
|
|
83
|
-
});
|
|
84
|
-
this.operationProcessor.disable();
|
|
85
82
|
applyErrorHandling(this, {
|
|
86
83
|
watch: { operation: "editing from code" },
|
|
87
|
-
handleCreatePage: { operation: "creating a page" },
|
|
88
84
|
handleReparent: { operation: "moving a component" },
|
|
89
85
|
handleCreateComponent: { operation: "creating a component" },
|
|
90
86
|
handleDeleteComponents: { operation: "deleting components" },
|
|
@@ -95,13 +91,9 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
95
91
|
handleUpdateApi: { operation: "updating an API" },
|
|
96
92
|
handleDeleteApi: { operation: "deleting an API" },
|
|
97
93
|
handleRenameApi: { operation: "renaming an API" },
|
|
98
|
-
handleAddEntity: { operation: "adding an entity" },
|
|
99
|
-
handleUpdateEntity: { operation: "updating an entity" },
|
|
100
|
-
handleDeleteEntity: { operation: "deleting an entity" },
|
|
101
94
|
handleRenameElement: { operation: "renaming an element" },
|
|
102
95
|
});
|
|
103
96
|
const methods = [
|
|
104
|
-
"handleCreatePage",
|
|
105
97
|
"handleReparent",
|
|
106
98
|
"handleCreateComponent",
|
|
107
99
|
"handleDeleteComponents",
|
|
@@ -112,9 +104,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
112
104
|
"handleUpdateApi",
|
|
113
105
|
"handleDeleteApi",
|
|
114
106
|
"handleRenameApi",
|
|
115
|
-
"handleAddEntity",
|
|
116
|
-
"handleUpdateEntity",
|
|
117
|
-
"handleDeleteEntity",
|
|
118
107
|
"handleRenameElement",
|
|
119
108
|
];
|
|
120
109
|
addTracingToMethods(this, methods, tracer);
|
|
@@ -141,11 +130,8 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
141
130
|
// this reads all files excluding ignore list in the root path. Should we read all files in pages and add root.tsx and App.tsx instead?
|
|
142
131
|
const tsxFiles = fileNames.filter((f) => f.endsWith(".tsx") && !f.includes(`${getLegacyComponentsFolder()}/`));
|
|
143
132
|
const yamlFiles = fileNames.filter((f) => f.endsWith(".yaml"));
|
|
144
|
-
const scopeFiles = fileNames.filter((f) => f.endsWith(SCOPE_FILE));
|
|
145
133
|
logger.info(`scanning ${tsxFiles.length} code files`);
|
|
146
134
|
logger.info(`scanning ${yamlFiles.length} api files`);
|
|
147
|
-
logger.info(`scanning app theme file`);
|
|
148
|
-
logger.info(`scanning ${scopeFiles.length} scope files`);
|
|
149
135
|
const allFiles = [
|
|
150
136
|
...tsxFiles.map((f) => {
|
|
151
137
|
return {
|
|
@@ -154,13 +140,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
154
140
|
content: readFile(f),
|
|
155
141
|
};
|
|
156
142
|
}),
|
|
157
|
-
...scopeFiles.map((f) => {
|
|
158
|
-
return {
|
|
159
|
-
type: "ts",
|
|
160
|
-
path: f,
|
|
161
|
-
content: readFile(f),
|
|
162
|
-
};
|
|
163
|
-
}),
|
|
164
143
|
...yamlFiles.map((f) => {
|
|
165
144
|
return {
|
|
166
145
|
type: "api",
|
|
@@ -188,20 +167,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
188
167
|
this.tsFiles[path] = content;
|
|
189
168
|
}
|
|
190
169
|
});
|
|
191
|
-
// And routes are in the root
|
|
192
|
-
const routePath = path.join(rootPath, ROUTES_FILE);
|
|
193
|
-
const routeFile = await readFile(routePath);
|
|
194
|
-
if (routeFile) {
|
|
195
|
-
try {
|
|
196
|
-
this.routes = JSON.parse(routeFile);
|
|
197
|
-
}
|
|
198
|
-
catch (e) {
|
|
199
|
-
logger.error("Error parsing routes file", getErrorMeta({
|
|
200
|
-
error: e,
|
|
201
|
-
routeFile,
|
|
202
|
-
}));
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
170
|
try {
|
|
206
171
|
this.initializeSourceTracker();
|
|
207
172
|
}
|
|
@@ -224,8 +189,28 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
224
189
|
this.updateInternalApiData(content, path);
|
|
225
190
|
}
|
|
226
191
|
});
|
|
192
|
+
// Find and store the router file path for watching
|
|
193
|
+
try {
|
|
194
|
+
this.routerFilePath = await findRouterFile(rootPath);
|
|
195
|
+
logger.info(`Router file found at: ${this.routerFilePath}`);
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
logger.error("No router file found", getErrorMeta(e));
|
|
199
|
+
this.routerFilePath = null;
|
|
200
|
+
}
|
|
227
201
|
watcher.on("all", (event, filePath) => {
|
|
228
|
-
|
|
202
|
+
if (event == "add" || event == "unlink") {
|
|
203
|
+
void this.handleFileChange(event, filePath);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
let handler = this.debouncedFileUpdateHandlers.get(filePath);
|
|
207
|
+
if (!handler) {
|
|
208
|
+
handler = debounce(() => {
|
|
209
|
+
void this.handleFileChange(event, filePath);
|
|
210
|
+
}, 100, { leading: true, trailing: true, maxWait: 500 });
|
|
211
|
+
this.debouncedFileUpdateHandlers.set(filePath, handler);
|
|
212
|
+
}
|
|
213
|
+
handler();
|
|
229
214
|
});
|
|
230
215
|
}
|
|
231
216
|
initializeSourceTracker() {
|
|
@@ -240,6 +225,59 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
240
225
|
}
|
|
241
226
|
return this.sourceTracker.handleNonVisualChangeByDeletingIds(path, content);
|
|
242
227
|
}
|
|
228
|
+
async getPropertyCode(itemId, propertyName) {
|
|
229
|
+
const logger = getLogger();
|
|
230
|
+
if (!this.sourceTracker) {
|
|
231
|
+
throw new Error("Source tracker not initialized");
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
// Get the element location (cast itemId to SbElement type)
|
|
235
|
+
const element = this.sourceTracker.getElementToLocation(itemId);
|
|
236
|
+
if (!element) {
|
|
237
|
+
logger.warn(`Element not found: ${itemId}`);
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
// Get the JSX opening element
|
|
241
|
+
let openingElement = null;
|
|
242
|
+
if (element.isJSXElement()) {
|
|
243
|
+
openingElement = element.get("openingElement");
|
|
244
|
+
}
|
|
245
|
+
else if (element.isJSXOpeningElement()) {
|
|
246
|
+
openingElement = element;
|
|
247
|
+
}
|
|
248
|
+
if (!openingElement) {
|
|
249
|
+
logger.warn(`Could not find opening element for: ${itemId}`);
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
// Find the attribute with the specified property name
|
|
253
|
+
const attributes = openingElement.get("attributes");
|
|
254
|
+
for (const attr of attributes) {
|
|
255
|
+
if (attr.isJSXAttribute()) {
|
|
256
|
+
const attrName = attr.get("name");
|
|
257
|
+
if (attrName.isJSXIdentifier() &&
|
|
258
|
+
attrName.node.name === propertyName) {
|
|
259
|
+
const value = attr.get("value");
|
|
260
|
+
// Handle different value types
|
|
261
|
+
if (value.isStringLiteral()) {
|
|
262
|
+
return value.node.value;
|
|
263
|
+
}
|
|
264
|
+
else if (value.isJSXExpressionContainer()) {
|
|
265
|
+
const expression = value.get("expression");
|
|
266
|
+
// Generate code from the expression
|
|
267
|
+
const code = generate(expression.node).code;
|
|
268
|
+
return code;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
logger.warn(`Property ${propertyName} not found on element ${itemId}`);
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
logger.error(`Error getting property code for ${itemId}.${propertyName}`, getErrorMeta(error));
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
243
281
|
async getFileWithIds(filePath) {
|
|
244
282
|
const logger = getLogger();
|
|
245
283
|
if (!this.sourceTracker) {
|
|
@@ -249,10 +287,22 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
249
287
|
if (!files[filePath]) {
|
|
250
288
|
throw new Error("File not found in source tracker " + filePath);
|
|
251
289
|
}
|
|
252
|
-
|
|
290
|
+
let ast = files[filePath].ast;
|
|
253
291
|
if (!ast) {
|
|
254
292
|
throw new Error("No AST found for file in source tracker " + filePath);
|
|
255
293
|
}
|
|
294
|
+
if (filePath in this.tsFiles &&
|
|
295
|
+
this.tsFiles[filePath] &&
|
|
296
|
+
files[filePath].code !== this.tsFiles[filePath]) {
|
|
297
|
+
getLogger().error("File code mismatch in source tracker, this should never happen: " +
|
|
298
|
+
filePath);
|
|
299
|
+
await this.handleNonVisualChangeByDeletingIds(filePath, this.tsFiles[filePath]);
|
|
300
|
+
const newAst = this.sourceTracker.getCurrentFiles()[filePath]?.ast;
|
|
301
|
+
if (!newAst) {
|
|
302
|
+
throw new Error("No AST found for file in source tracker after mismatch:" + filePath);
|
|
303
|
+
}
|
|
304
|
+
ast = newAst;
|
|
305
|
+
}
|
|
256
306
|
const jsxVariables = [];
|
|
257
307
|
traverse(ast, {
|
|
258
308
|
VariableDeclarator(path) {
|
|
@@ -389,15 +439,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
389
439
|
return null;
|
|
390
440
|
}
|
|
391
441
|
}
|
|
392
|
-
enableOperationsQueue() {
|
|
393
|
-
this.operationProcessor.enable();
|
|
394
|
-
}
|
|
395
|
-
disableOperationsQueue() {
|
|
396
|
-
this.operationProcessor.disable();
|
|
397
|
-
}
|
|
398
|
-
async flushOperations() {
|
|
399
|
-
await this.operationProcessor.flush();
|
|
400
|
-
}
|
|
401
442
|
// MARK: file change handling
|
|
402
443
|
handleFileChange = async (event, filePath) => {
|
|
403
444
|
const logger = getLogger();
|
|
@@ -410,7 +451,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
410
451
|
if (event === "addDir" || event === "unlinkDir") {
|
|
411
452
|
return;
|
|
412
453
|
}
|
|
413
|
-
const routePath = path.join(rootPath, ROUTES_FILE);
|
|
414
454
|
const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
|
|
415
455
|
// Only handle files we care about and that are in our root path
|
|
416
456
|
if (!fileType || !filePath.startsWith(rootPath)) {
|
|
@@ -419,143 +459,89 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
419
459
|
// Queue the operation based on the event type
|
|
420
460
|
switch (event) {
|
|
421
461
|
case "add": {
|
|
422
|
-
const
|
|
423
|
-
if (typeof
|
|
462
|
+
const file = await readFile(filePath);
|
|
463
|
+
if (typeof file !== "string")
|
|
424
464
|
return;
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
this.emit("addPage", filePath);
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
void this.operationProcessor.addOperation({
|
|
447
|
-
metadata: {
|
|
448
|
-
filePath,
|
|
449
|
-
},
|
|
450
|
-
execute: async () => {
|
|
451
|
-
switch (fileType.type) {
|
|
452
|
-
case "api":
|
|
453
|
-
case "python-api-step":
|
|
454
|
-
case "js-api-step": {
|
|
455
|
-
await this.processApiFileUpdates(filePath, fileType);
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
},
|
|
460
|
-
});
|
|
465
|
+
switch (fileType.type) {
|
|
466
|
+
case "api":
|
|
467
|
+
case "python-api-step":
|
|
468
|
+
case "js-api-step": {
|
|
469
|
+
await this.processApiFileUpdates(filePath, fileType);
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
case "ts":
|
|
473
|
+
case "tsx":
|
|
474
|
+
if (!(filePath in this.tsFiles)) {
|
|
475
|
+
this.tsFiles[filePath] = file;
|
|
476
|
+
await this.handleNonVisualChangeByDeletingIds(filePath, file);
|
|
477
|
+
this.emit("fileChanged", filePath, file, true);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
461
480
|
}
|
|
462
481
|
break;
|
|
463
482
|
}
|
|
464
483
|
case "change": {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
// this.addRoute assigns this.routes itself, causing this.routes === data
|
|
477
|
-
// but we still want to emit the event to HMR root.tsx
|
|
478
|
-
this.emit("routesChanged", this.routes);
|
|
479
|
-
}
|
|
480
|
-
catch (e) {
|
|
481
|
-
logger.error("Error parsing routes file", getErrorMeta(e));
|
|
482
|
-
}
|
|
483
|
-
},
|
|
484
|
-
});
|
|
484
|
+
const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
|
|
485
|
+
if (!fileType || !filePath.startsWith(rootPath)) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const data = await readFile(filePath);
|
|
489
|
+
if (typeof data !== "string")
|
|
490
|
+
return;
|
|
491
|
+
// Handle router file changes
|
|
492
|
+
if (this.routerFilePath && filePath === this.routerFilePath) {
|
|
493
|
+
logger.info("Router file changed, emitting routerChange event");
|
|
494
|
+
this.emit("routerChange", filePath);
|
|
485
495
|
return;
|
|
486
496
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
497
|
+
switch (fileType.type) {
|
|
498
|
+
case "ts":
|
|
499
|
+
case "tsx":
|
|
500
|
+
case "scope":
|
|
501
|
+
{
|
|
502
|
+
if (!(filePath in this.tsFiles && this.tsFiles[filePath] === data)) {
|
|
503
|
+
logger.info(`File changed: ${filePath} updating AST tracker`);
|
|
504
|
+
this.tsFiles[filePath] = data;
|
|
505
|
+
// only update the source tracker if the file is different
|
|
506
|
+
await this.handleNonVisualChangeByDeletingIds(filePath, data);
|
|
507
|
+
this.emit("fileChanged", filePath, data, true);
|
|
496
508
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
case "tsx":
|
|
502
|
-
case "scope":
|
|
503
|
-
{
|
|
504
|
-
// We do not want to trigger ANY side effects for page additions, we want to control these
|
|
505
|
-
// in the addPage handler itself so we can control the order of events
|
|
506
|
-
if (this.pageAdditionQueue.has(filePath)) {
|
|
507
|
-
logger.info(`File changed: ${filePath} is a page addition, skipping side effects`);
|
|
508
|
-
this.pageAdditionQueue.delete(filePath);
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
if (!(filePath in this.tsFiles &&
|
|
512
|
-
this.tsFiles[filePath] === data)) {
|
|
513
|
-
logger.info(`File changed: ${filePath} updating AST tracker`);
|
|
514
|
-
this.tsFiles[filePath] = data;
|
|
515
|
-
// only update the source tracker if the file is different
|
|
516
|
-
await this.handleNonVisualChangeByDeletingIds(filePath, data);
|
|
517
|
-
this.emit("fileChanged", filePath, data, true);
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
logger.info(`File unchanged from last tracked state: ${filePath}`);
|
|
521
|
-
this.emit("fileChanged", filePath, data, false);
|
|
522
|
-
this.sourceTracker?.updateFileContents(filePath, data);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
break;
|
|
526
|
-
case "api":
|
|
527
|
-
case "python-api-step":
|
|
528
|
-
case "js-api-step":
|
|
529
|
-
{
|
|
530
|
-
await this.processApiFileUpdates(filePath, fileType);
|
|
531
|
-
}
|
|
532
|
-
break;
|
|
509
|
+
else {
|
|
510
|
+
logger.info(`File unchanged from last tracked state: ${filePath}`);
|
|
511
|
+
this.emit("fileChanged", filePath, data, false);
|
|
512
|
+
this.sourceTracker?.updateFileContents(filePath, data);
|
|
533
513
|
}
|
|
534
|
-
}
|
|
535
|
-
|
|
514
|
+
}
|
|
515
|
+
break;
|
|
516
|
+
case "api":
|
|
517
|
+
case "python-api-step":
|
|
518
|
+
case "js-api-step":
|
|
519
|
+
{
|
|
520
|
+
await this.processApiFileUpdates(filePath, fileType);
|
|
521
|
+
}
|
|
522
|
+
break;
|
|
536
523
|
}
|
|
537
524
|
break;
|
|
538
525
|
}
|
|
539
526
|
case "unlink": {
|
|
540
527
|
if (filePath in this.tsFiles) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
528
|
+
await this.deleteTsFile(filePath);
|
|
529
|
+
if (this.routerFilePath && filePath === this.routerFilePath) {
|
|
530
|
+
logger.warn("Router file was deleted, attempting to find new router file");
|
|
531
|
+
try {
|
|
532
|
+
this.routerFilePath = await findRouterFile(rootPath);
|
|
533
|
+
logger.info(`New router file found at: ${this.routerFilePath}`);
|
|
534
|
+
this.emit("routerChange", this.routerFilePath);
|
|
535
|
+
}
|
|
536
|
+
catch {
|
|
537
|
+
this.routerFilePath = null;
|
|
538
|
+
const error = new Error("Router file was deleted and no replacement could be found.");
|
|
539
|
+
logger.error("Router file missing", getErrorMeta(error));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
549
542
|
}
|
|
550
543
|
else if (filePath in this.apiFiles) {
|
|
551
|
-
|
|
552
|
-
metadata: {
|
|
553
|
-
filePath,
|
|
554
|
-
},
|
|
555
|
-
execute: async () => {
|
|
556
|
-
await this.removeApiData(filePath);
|
|
557
|
-
},
|
|
558
|
-
});
|
|
544
|
+
await this.removeApiData(filePath);
|
|
559
545
|
}
|
|
560
546
|
break;
|
|
561
547
|
}
|
|
@@ -620,21 +606,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
620
606
|
readFile(path) {
|
|
621
607
|
return this.tsFiles[path];
|
|
622
608
|
}
|
|
623
|
-
async addRoute(route, filePath) {
|
|
624
|
-
if (!this.rootDir) {
|
|
625
|
-
throw new Error("Root directory not set");
|
|
626
|
-
}
|
|
627
|
-
this.routes[route] = { file: this.getRelativeRoutePath(filePath) };
|
|
628
|
-
await this.writeFile(path.join(this.rootDir, ROUTES_FILE), JSON.stringify(this.routes, null, 2));
|
|
629
|
-
}
|
|
630
|
-
async removeRoute(filePath) {
|
|
631
|
-
if (!this.rootDir) {
|
|
632
|
-
throw new Error("Root directory not set");
|
|
633
|
-
}
|
|
634
|
-
const relativeFilePath = this.getRelativeRoutePath(filePath);
|
|
635
|
-
this.routes = Object.fromEntries(Object.entries(this.routes).filter(([_, value]) => value.file !== relativeFilePath));
|
|
636
|
-
await this.writeFile(path.join(this.rootDir, ROUTES_FILE), JSON.stringify(this.routes, null, 2));
|
|
637
|
-
}
|
|
638
609
|
async writeChanges(changes, callback) {
|
|
639
610
|
return Promise.all(changes.map(async ({ fileName, source, kind }) => {
|
|
640
611
|
await this.writeFile(fileName, source, kind);
|
|
@@ -733,26 +704,24 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
733
704
|
const roots = getRootNodes(filePath, currentFile);
|
|
734
705
|
return [...roots, ...importedRoots];
|
|
735
706
|
}
|
|
736
|
-
getScope(filePath) {
|
|
737
|
-
//
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
const routes = [];
|
|
749
|
-
for (const [path, { file }] of Object.entries(this.routes)) {
|
|
750
|
-
routes.push({
|
|
751
|
-
path,
|
|
752
|
-
component: file,
|
|
753
|
-
});
|
|
707
|
+
getScope(filePath, fallback) {
|
|
708
|
+
// Since we no longer use scope.ts files, generate scope info from file path. Pages retain page scope, everything else is App.
|
|
709
|
+
const scopeName = getScopeNameFromPath(filePath);
|
|
710
|
+
if (!scopeName) {
|
|
711
|
+
if (fallback) {
|
|
712
|
+
return {
|
|
713
|
+
entities: {},
|
|
714
|
+
scopeName: "App",
|
|
715
|
+
scopeId: getScopeIdFromName("App"),
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
return undefined;
|
|
754
719
|
}
|
|
755
|
-
return
|
|
720
|
+
return {
|
|
721
|
+
entities: {},
|
|
722
|
+
scopeName,
|
|
723
|
+
scopeId: getScopeIdFromName(scopeName),
|
|
724
|
+
};
|
|
756
725
|
}
|
|
757
726
|
// MARK: transaction handling
|
|
758
727
|
flushTransactions = () => {
|
|
@@ -774,80 +743,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
774
743
|
return this.processedTransactions.concat(nonce);
|
|
775
744
|
}
|
|
776
745
|
// MARK: editor operations
|
|
777
|
-
handleCreatePage = async (payload) => {
|
|
778
|
-
this.trackTransaction(payload.transaction?.id);
|
|
779
|
-
const { name, route, navigateToRoute } = payload;
|
|
780
|
-
if (!this.rootDir) {
|
|
781
|
-
throw new Error("Root directory not set");
|
|
782
|
-
}
|
|
783
|
-
if (!route) {
|
|
784
|
-
throw new Error("Route is required when creating a page");
|
|
785
|
-
}
|
|
786
|
-
const pagePath = getPageFolder(this.rootDir, name);
|
|
787
|
-
const pageIndexPath = path.join(pagePath, "index.tsx");
|
|
788
|
-
const scopePath = path.join(pagePath, "scope.ts");
|
|
789
|
-
const pageContent = /*js*/ `import { Page, Dim, registerPage } from "@superblocksteam/library";
|
|
790
|
-
import Stack from "@/components/ui/stack/index";
|
|
791
|
-
import { ${name}, ${name}Scope } from "./scope";
|
|
792
|
-
|
|
793
|
-
function PageContent() {
|
|
794
|
-
const {} = ${name};
|
|
795
|
-
return (
|
|
796
|
-
<Page name="${name}" height={Dim.fill()} width={Dim.fill()}>
|
|
797
|
-
<Stack
|
|
798
|
-
height={Dim.fill()}
|
|
799
|
-
width={Dim.fill()}
|
|
800
|
-
layout="vertical"
|
|
801
|
-
verticalAlign="top"
|
|
802
|
-
horizontalAlign="center"
|
|
803
|
-
shouldScrollContents
|
|
804
|
-
></Stack>
|
|
805
|
-
</Page>
|
|
806
|
-
);
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
export default registerPage(PageContent, ${name}Scope);
|
|
810
|
-
`;
|
|
811
|
-
const scopeContent = /*js*/ `/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
812
|
-
/* eslint-disable no-empty-pattern */
|
|
813
|
-
import { createScope, computed, Global } from "@superblocksteam/library";
|
|
814
|
-
import { App } from "@/scope";
|
|
815
|
-
import { toast } from "sonner";
|
|
816
|
-
|
|
817
|
-
export const ${name}Scope = createScope<{}>(({ entities }) => ({}), {
|
|
818
|
-
name: "${name}",
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
export const ${name} = ${name}Scope.entities;
|
|
822
|
-
`;
|
|
823
|
-
this.watcher?.unwatch(pagePath);
|
|
824
|
-
await fs.mkdir(pagePath, { recursive: true });
|
|
825
|
-
await this.writeFile(pageIndexPath, pageContent, "ts");
|
|
826
|
-
await this.writeFile(scopePath, scopeContent, "ts");
|
|
827
|
-
await this.handleNonVisualChangeByDeletingIds(pageIndexPath, pageContent);
|
|
828
|
-
await this.handleNonVisualChangeByDeletingIds(scopePath, scopeContent);
|
|
829
|
-
this.pageAdditionQueue.add(pageIndexPath);
|
|
830
|
-
this.pageAdditionQueue.add(scopePath);
|
|
831
|
-
this.watcher?.add(pagePath);
|
|
832
|
-
await this.addRoute(route, pageIndexPath);
|
|
833
|
-
this.emit("addPage", pageIndexPath, navigateToRoute ? route : undefined);
|
|
834
|
-
};
|
|
835
|
-
handleDeletePage = async (payload) => {
|
|
836
|
-
const { name, transaction } = payload;
|
|
837
|
-
this.trackTransaction(transaction?.id);
|
|
838
|
-
if (Object.values(this.routes).length === 1) {
|
|
839
|
-
throw new Error("You can't delete the last page");
|
|
840
|
-
}
|
|
841
|
-
if (!this.rootDir) {
|
|
842
|
-
throw new Error("Root directory not set");
|
|
843
|
-
}
|
|
844
|
-
const pagePath = getPageFolder(this.rootDir, name);
|
|
845
|
-
const pageIndexPath = path.join(pagePath, "index.tsx");
|
|
846
|
-
this.watcher?.unwatch(pagePath);
|
|
847
|
-
await this.removeRoute(pageIndexPath);
|
|
848
|
-
await fs.rm(pagePath, { recursive: true, force: true });
|
|
849
|
-
this.emit("deletePage", pagePath);
|
|
850
|
-
};
|
|
851
746
|
get routeChange() {
|
|
852
747
|
return this.routeChangesQueue.shift();
|
|
853
748
|
}
|
|
@@ -973,70 +868,18 @@ export const ${name} = ${name}Scope.entities;
|
|
|
973
868
|
this.flushTransactions();
|
|
974
869
|
return returnValues;
|
|
975
870
|
};
|
|
976
|
-
// MARK: entity operations
|
|
977
|
-
handleAddEntity = async (payload) => {
|
|
978
|
-
this.sourceTracker?.addEntity({
|
|
979
|
-
scopeId: payload.scopeId,
|
|
980
|
-
entity: {
|
|
981
|
-
type: payload.type,
|
|
982
|
-
name: payload.name,
|
|
983
|
-
attributes: payload.attributes,
|
|
984
|
-
},
|
|
985
|
-
});
|
|
986
|
-
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
987
|
-
await this.writeChanges(changes, (fileName) => {
|
|
988
|
-
this.emit("addEntity", fileName, payload);
|
|
989
|
-
});
|
|
990
|
-
};
|
|
991
|
-
handleUpdateEntity = async (payload) => {
|
|
992
|
-
this.sourceTracker?.updateEntity({
|
|
993
|
-
entityId: payload.entityId,
|
|
994
|
-
updates: payload.updates,
|
|
995
|
-
});
|
|
996
|
-
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
997
|
-
await this.writeChanges(changes, (fileName) => {
|
|
998
|
-
this.emit("updateEntity", fileName, payload);
|
|
999
|
-
});
|
|
1000
|
-
};
|
|
1001
|
-
handleDeleteEntity = async (payload) => {
|
|
1002
|
-
const deletedEntityName = this.sourceTracker?.deleteEntity({
|
|
1003
|
-
entityId: payload.entityId,
|
|
1004
|
-
});
|
|
1005
|
-
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
1006
|
-
await this.writeChanges(changes, (fileName) => {
|
|
1007
|
-
if (deletedEntityName) {
|
|
1008
|
-
this.emit("deleteEntity", fileName, deletedEntityName);
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
};
|
|
1012
|
-
handleAddComponentNameToScope = async (payload) => {
|
|
1013
|
-
const { scopeName, componentName } = payload;
|
|
1014
|
-
this.sourceTracker?.addScopeComponent({
|
|
1015
|
-
scopeName,
|
|
1016
|
-
componentName,
|
|
1017
|
-
});
|
|
1018
|
-
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
1019
|
-
await this.writeChanges(changes);
|
|
1020
|
-
};
|
|
1021
871
|
// MARK: rename operations
|
|
1022
872
|
handleRenameElement = async (payload) => {
|
|
1023
873
|
if (payload.kind === "component") {
|
|
1024
874
|
return this.handleRenameComponent(payload);
|
|
1025
875
|
}
|
|
1026
|
-
else if (payload.kind === "entity") {
|
|
1027
|
-
return this.handleRenameEntity(payload);
|
|
1028
|
-
}
|
|
1029
|
-
else if (payload.kind === "page") {
|
|
1030
|
-
return this.handleRenamePage(payload);
|
|
1031
|
-
}
|
|
1032
876
|
};
|
|
1033
877
|
handleRenameComponent = async (payload) => {
|
|
1034
|
-
const { elementId, newName, oldName,
|
|
878
|
+
const { elementId, newName, oldName, renameInAst } = payload;
|
|
1035
879
|
await this.sourceTracker?.renameComponent({
|
|
1036
880
|
widgetSourceId: elementId,
|
|
1037
881
|
oldName,
|
|
1038
882
|
newName,
|
|
1039
|
-
scopeName,
|
|
1040
883
|
renameInAst,
|
|
1041
884
|
});
|
|
1042
885
|
await this.renameIdentifierInApis({
|
|
@@ -1049,183 +892,6 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1049
892
|
this.emit("renameComponent", fileName);
|
|
1050
893
|
});
|
|
1051
894
|
};
|
|
1052
|
-
handleRenameEntity = async (payload) => {
|
|
1053
|
-
const { elementId, newName, oldName, scopeName } = payload;
|
|
1054
|
-
this.sourceTracker?.renameEntity({
|
|
1055
|
-
entityId: elementId,
|
|
1056
|
-
oldName,
|
|
1057
|
-
newName,
|
|
1058
|
-
scopeName,
|
|
1059
|
-
});
|
|
1060
|
-
await this.renameIdentifierInApis(payload);
|
|
1061
|
-
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
1062
|
-
await this.writeChanges(changes, (fileName) => {
|
|
1063
|
-
this.emit("renameEntity", fileName);
|
|
1064
|
-
});
|
|
1065
|
-
};
|
|
1066
|
-
handleRenamePage = async (payload) => {
|
|
1067
|
-
const { newName, oldName } = payload;
|
|
1068
|
-
if (!this.rootDir) {
|
|
1069
|
-
throw new Error("Root directory not set");
|
|
1070
|
-
}
|
|
1071
|
-
try {
|
|
1072
|
-
await this.performRenamePageTransaction(oldName, newName);
|
|
1073
|
-
this.emit("renamePage", newName);
|
|
1074
|
-
}
|
|
1075
|
-
catch (error) {
|
|
1076
|
-
getLogger().error("Error renaming page", getErrorMeta(error));
|
|
1077
|
-
throw error;
|
|
1078
|
-
}
|
|
1079
|
-
};
|
|
1080
|
-
/**
|
|
1081
|
-
* As much as possible, we want to perform the rename page transaction as an operation we can roll back if it fails.
|
|
1082
|
-
*/
|
|
1083
|
-
async performRenamePageTransaction(oldName, newName) {
|
|
1084
|
-
let snapshot;
|
|
1085
|
-
let changes;
|
|
1086
|
-
try {
|
|
1087
|
-
if (!this.rootDir) {
|
|
1088
|
-
throw new Error("Root directory not set");
|
|
1089
|
-
}
|
|
1090
|
-
const newPageFolder = getPageFolder(this.rootDir, newName);
|
|
1091
|
-
const oldPageFolder = getPageFolder(this.rootDir, oldName);
|
|
1092
|
-
const newIndexFilePath = path.join(newPageFolder, "index.tsx");
|
|
1093
|
-
const oldIndexFilePath = path.join(oldPageFolder, "index.tsx");
|
|
1094
|
-
const oldScopeFilePath = path.join(oldPageFolder, SCOPE_FILE);
|
|
1095
|
-
const newScopeFilePath = path.join(newPageFolder, SCOPE_FILE);
|
|
1096
|
-
// Early validations
|
|
1097
|
-
const doesFileExist = await fs.stat(newIndexFilePath).catch(() => false);
|
|
1098
|
-
if (doesFileExist) {
|
|
1099
|
-
throw new Error(`Page ${newName} already exists`);
|
|
1100
|
-
}
|
|
1101
|
-
const existingRoute = Object.keys(this.routes).find((route) => this.routes[route]?.file ===
|
|
1102
|
-
this.getRelativeRoutePath(oldIndexFilePath));
|
|
1103
|
-
if (!existingRoute) {
|
|
1104
|
-
throw new Error(`Route for ${oldName} not found`);
|
|
1105
|
-
}
|
|
1106
|
-
const oldScope = this.sourceTracker?.getScopeDefinitionForPage(oldName);
|
|
1107
|
-
if (!oldScope) {
|
|
1108
|
-
throw new Error(`Scope definition not found for old page, ${oldName}`);
|
|
1109
|
-
}
|
|
1110
|
-
snapshot = {
|
|
1111
|
-
tsFiles: { ...this.tsFiles },
|
|
1112
|
-
apiFiles: { ...this.apiFiles },
|
|
1113
|
-
routes: { ...this.routes },
|
|
1114
|
-
};
|
|
1115
|
-
changes = {
|
|
1116
|
-
newPageFolder,
|
|
1117
|
-
oldPageFolder,
|
|
1118
|
-
newIndexFilePath,
|
|
1119
|
-
oldIndexFilePath,
|
|
1120
|
-
newScopeFilePath,
|
|
1121
|
-
oldScopeFilePath,
|
|
1122
|
-
oldScope,
|
|
1123
|
-
existingRoute,
|
|
1124
|
-
};
|
|
1125
|
-
await this.commitRenamePageChanges(oldName, newName, changes);
|
|
1126
|
-
}
|
|
1127
|
-
catch (error) {
|
|
1128
|
-
if (snapshot && changes) {
|
|
1129
|
-
await this.rollbackRenamePageChanges(snapshot, changes);
|
|
1130
|
-
}
|
|
1131
|
-
throw error;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
async commitRenamePageChanges(oldName, newName, changes) {
|
|
1135
|
-
const { newPageFolder, oldPageFolder, newIndexFilePath, oldIndexFilePath, newScopeFilePath, oldScopeFilePath, existingRoute, } = changes;
|
|
1136
|
-
// we don't want to trigger fs events during the operation
|
|
1137
|
-
this.watcher?.unwatch(newPageFolder);
|
|
1138
|
-
this.watcher?.unwatch(oldPageFolder);
|
|
1139
|
-
await fs.cp(oldPageFolder, newPageFolder, { recursive: true });
|
|
1140
|
-
const newIndexFile = await readFile(newIndexFilePath);
|
|
1141
|
-
if (!newIndexFile) {
|
|
1142
|
-
throw new Error(`New index file ${newIndexFilePath} not found`);
|
|
1143
|
-
}
|
|
1144
|
-
const newScopeFile = await readFile(newScopeFilePath);
|
|
1145
|
-
if (!newScopeFile) {
|
|
1146
|
-
throw new Error(`New scope file ${newScopeFilePath} not found`);
|
|
1147
|
-
}
|
|
1148
|
-
delete this.tsFiles[oldIndexFilePath];
|
|
1149
|
-
delete this.tsFiles[oldScopeFilePath];
|
|
1150
|
-
// lets setup all the ast stuff for the new files
|
|
1151
|
-
await this.handleNonVisualChangeByDeletingIds(newScopeFilePath, newScopeFile);
|
|
1152
|
-
await this.handleNonVisualChangeByDeletingIds(newIndexFilePath, newIndexFile);
|
|
1153
|
-
Object.entries(this.tsFiles).forEach(([key, value]) => {
|
|
1154
|
-
if (key.startsWith(oldPageFolder)) {
|
|
1155
|
-
this.tsFiles[key.replace(oldPageFolder, newPageFolder)] = value;
|
|
1156
|
-
delete this.tsFiles[key];
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
// perform the page rename in source tracker now that we have the ast stuff setup
|
|
1160
|
-
this.sourceTracker?.renamePage({
|
|
1161
|
-
oldName,
|
|
1162
|
-
newName,
|
|
1163
|
-
scopeFilePath: newScopeFilePath,
|
|
1164
|
-
pageFilePath: newIndexFilePath,
|
|
1165
|
-
});
|
|
1166
|
-
const newScope = this.sourceTracker?.getScopeDefinitionForPage(newName);
|
|
1167
|
-
if (!newScope) {
|
|
1168
|
-
throw new Error(`Scope definition not found for new page, ${newName}`);
|
|
1169
|
-
}
|
|
1170
|
-
// our apis need the new scope id info, otherwise ui loses track
|
|
1171
|
-
Object.entries(this.apiFiles).forEach(([key, value]) => {
|
|
1172
|
-
if (key.startsWith(oldPageFolder)) {
|
|
1173
|
-
this.apiFiles[key.replace(oldPageFolder, newPageFolder)] = {
|
|
1174
|
-
...value,
|
|
1175
|
-
apiPb: {
|
|
1176
|
-
...value.apiPb,
|
|
1177
|
-
trigger: {
|
|
1178
|
-
...value.apiPb.trigger,
|
|
1179
|
-
pageName: newName,
|
|
1180
|
-
pageId: newScope.id,
|
|
1181
|
-
},
|
|
1182
|
-
},
|
|
1183
|
-
scopeId: newScope.id,
|
|
1184
|
-
pageName: newName,
|
|
1185
|
-
};
|
|
1186
|
-
delete this.apiFiles[key];
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
await this.removeRoute(oldIndexFilePath);
|
|
1190
|
-
await this.addRoute(existingRoute, newIndexFilePath);
|
|
1191
|
-
await this.sourceTracker?.removeFile(oldIndexFilePath);
|
|
1192
|
-
await this.sourceTracker?.removeFile(oldScopeFilePath);
|
|
1193
|
-
// write all changes
|
|
1194
|
-
const sourceChanges = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
1195
|
-
await this.writeChanges(sourceChanges);
|
|
1196
|
-
this.watcher?.add(newPageFolder);
|
|
1197
|
-
// should be safe to delete the old page folder now
|
|
1198
|
-
await fs.rm(oldPageFolder, { recursive: true });
|
|
1199
|
-
}
|
|
1200
|
-
async rollbackRenamePageChanges(snapshot, changes) {
|
|
1201
|
-
const { newPageFolder, oldPageFolder, oldScopeFilePath, oldIndexFilePath } = changes;
|
|
1202
|
-
try {
|
|
1203
|
-
this.tsFiles = snapshot.tsFiles;
|
|
1204
|
-
this.apiFiles = snapshot.apiFiles;
|
|
1205
|
-
this.routes = snapshot.routes;
|
|
1206
|
-
// clean up the folders that were created
|
|
1207
|
-
await fs.rm(newPageFolder, { recursive: true }).catch((error) => {
|
|
1208
|
-
getLogger().warn(`Failed to delete new page folder ${newPageFolder} during rollback. Error: ${error}`);
|
|
1209
|
-
});
|
|
1210
|
-
const oldScopeFile = await readFile(oldScopeFilePath).catch(() => null);
|
|
1211
|
-
if (oldScopeFile) {
|
|
1212
|
-
await this.handleNonVisualChangeByDeletingIds(oldScopeFilePath, oldScopeFile);
|
|
1213
|
-
}
|
|
1214
|
-
const oldIndexFile = await readFile(oldIndexFilePath).catch(() => null);
|
|
1215
|
-
if (oldIndexFile) {
|
|
1216
|
-
await this.handleNonVisualChangeByDeletingIds(oldIndexFilePath, oldIndexFile);
|
|
1217
|
-
}
|
|
1218
|
-
// ensure we have the the correct routes on disk
|
|
1219
|
-
if (this.rootDir) {
|
|
1220
|
-
await this.writeFile(path.join(this.rootDir, ROUTES_FILE), JSON.stringify(snapshot.routes, null, 2));
|
|
1221
|
-
}
|
|
1222
|
-
// resume watching the original folder
|
|
1223
|
-
this.watcher?.add(oldPageFolder);
|
|
1224
|
-
}
|
|
1225
|
-
catch (rollbackError) {
|
|
1226
|
-
getLogger().error("Error during transaction rollback", getErrorMeta(rollbackError));
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
895
|
getRelativeRoutePath(filePath) {
|
|
1230
896
|
if (!this.rootDir) {
|
|
1231
897
|
throw new Error("Root directory not set");
|
|
@@ -1242,14 +908,11 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1242
908
|
if (!this.rootDir) {
|
|
1243
909
|
throw new Error("Root directory not set");
|
|
1244
910
|
}
|
|
1245
|
-
if (!api.pageName) {
|
|
1246
|
-
throw new Error("API page name is not set");
|
|
1247
|
-
}
|
|
1248
911
|
const apiName = api.apiPb.metadata.name;
|
|
1249
912
|
if (!apiName) {
|
|
1250
913
|
throw new Error("API name is not set");
|
|
1251
914
|
}
|
|
1252
|
-
const apiFilePath = getApiFilePath(this.rootDir,
|
|
915
|
+
const apiFilePath = getApiFilePath(this.rootDir, apiName);
|
|
1253
916
|
const apiDir = path.dirname(apiFilePath);
|
|
1254
917
|
const isNewApi = !this.getApiFiles()[apiFilePath];
|
|
1255
918
|
try {
|
|
@@ -1263,14 +926,10 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1263
926
|
}
|
|
1264
927
|
await this.writeFile(apiFilePath, yaml.stringify(api.apiPb), "api");
|
|
1265
928
|
const generationNumber = this.generationNumberSequence.next();
|
|
929
|
+
const scopeId = getScopeIdFromName("App");
|
|
1266
930
|
const apiDef = this.createClientApi(api);
|
|
1267
|
-
let scopeId = "";
|
|
1268
931
|
if (isNewApi) {
|
|
1269
|
-
|
|
1270
|
-
}
|
|
1271
|
-
else {
|
|
1272
|
-
const scopeDef = this.sourceTracker.getScopeDefinitionForPage(api.pageName);
|
|
1273
|
-
scopeId = scopeDef?.id ?? "";
|
|
932
|
+
await this.addApiToScope(api);
|
|
1274
933
|
}
|
|
1275
934
|
this.emit("apiUpdate", { api: apiDef, scopeId });
|
|
1276
935
|
return { api: apiDef, scopeId, generationNumber };
|
|
@@ -1283,8 +942,8 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1283
942
|
}
|
|
1284
943
|
const rootDir = this.rootDir;
|
|
1285
944
|
const deletedApis = [];
|
|
1286
|
-
for (const { apiName
|
|
1287
|
-
const apiFilePath = getApiFilePath(rootDir,
|
|
945
|
+
for (const { apiName } of apis) {
|
|
946
|
+
const apiFilePath = getApiFilePath(rootDir, apiName);
|
|
1288
947
|
const api = this.apiFiles[apiFilePath];
|
|
1289
948
|
if (!api || !this.sourceTracker) {
|
|
1290
949
|
continue;
|
|
@@ -1297,12 +956,10 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1297
956
|
}
|
|
1298
957
|
delete this.apiFiles[apiFilePath];
|
|
1299
958
|
const scopeId = this.sourceTracker.deleteApi({
|
|
1300
|
-
pageName,
|
|
1301
959
|
apiName,
|
|
1302
960
|
});
|
|
1303
961
|
deletedApis.push({
|
|
1304
962
|
apiName,
|
|
1305
|
-
pageName,
|
|
1306
963
|
scopeId,
|
|
1307
964
|
});
|
|
1308
965
|
}
|
|
@@ -1318,25 +975,19 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1318
975
|
return { deletedApis };
|
|
1319
976
|
};
|
|
1320
977
|
handleRenameApi = async (payload) => {
|
|
1321
|
-
const { oldName, newName
|
|
978
|
+
const { oldName, newName } = payload;
|
|
1322
979
|
if (!this.rootDir) {
|
|
1323
980
|
throw new Error("Root directory not set");
|
|
1324
981
|
}
|
|
1325
|
-
const
|
|
1326
|
-
const
|
|
1327
|
-
const newApiFolder = path.join(this.rootDir, "pages", pageName, "apis", newName);
|
|
1328
|
-
const files = this.sourceTracker?.getCurrentFiles();
|
|
1329
|
-
const file = files?.[path.join(pagePath, "index.tsx")];
|
|
1330
|
-
if (!file || !file.ast) {
|
|
1331
|
-
throw new Error(`Page ${pageName} not found`);
|
|
1332
|
-
}
|
|
982
|
+
const existingApiFolder = path.join(this.rootDir, "apis", oldName);
|
|
983
|
+
const newApiFolder = path.join(this.rootDir, "apis", newName);
|
|
1333
984
|
const apiFilePath = path.join(existingApiFolder, "api.yaml");
|
|
1334
985
|
const apiDef = this.apiFiles[apiFilePath];
|
|
1335
986
|
if (!apiDef) {
|
|
1336
987
|
throw new Error(`API ${oldName} not found`);
|
|
1337
988
|
}
|
|
1338
|
-
const
|
|
1339
|
-
.filter((path) => path
|
|
989
|
+
const otherAPIs = structuredClone(Object.keys(this.apiFiles)
|
|
990
|
+
.filter((path) => path !== apiFilePath)
|
|
1340
991
|
.map((path) => ({
|
|
1341
992
|
api: { apiPb: this.apiFiles[path]?.apiPb },
|
|
1342
993
|
filePath: path,
|
|
@@ -1350,15 +1001,7 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1350
1001
|
this.watcher?.unwatch(newApiFolder);
|
|
1351
1002
|
apiDef.apiPb.metadata.name = newName;
|
|
1352
1003
|
await fs.rename(existingApiFolder, newApiFolder);
|
|
1353
|
-
const
|
|
1354
|
-
if (!scopeDef) {
|
|
1355
|
-
throw new Error(`Scope definition not found for API`);
|
|
1356
|
-
}
|
|
1357
|
-
this.sourceTracker?.renameEntity({
|
|
1358
|
-
oldName,
|
|
1359
|
-
newName,
|
|
1360
|
-
entityId: scopeDef.scopeNameToEntityId[oldName],
|
|
1361
|
-
});
|
|
1004
|
+
const scopeId = getScopeIdFromName("App");
|
|
1362
1005
|
delete this.apiFiles[apiFilePath];
|
|
1363
1006
|
// not waiting because we are queueing the write further down
|
|
1364
1007
|
void this.writeFile(path.join(newApiFolder, "api.yaml"), yaml.stringify(apiDef.apiPb), "api");
|
|
@@ -1369,26 +1012,23 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1369
1012
|
this.emit("apiManualUpdate", {
|
|
1370
1013
|
api: this.createClientApi(apiDef),
|
|
1371
1014
|
oldName,
|
|
1372
|
-
|
|
1373
|
-
scopeId: scopeDef?.id ?? "",
|
|
1015
|
+
scopeId,
|
|
1374
1016
|
}, true);
|
|
1375
1017
|
await this.renameManager.renameEntityInApis({
|
|
1376
1018
|
oldName,
|
|
1377
1019
|
newName,
|
|
1378
|
-
apis:
|
|
1020
|
+
apis: otherAPIs,
|
|
1379
1021
|
});
|
|
1380
1022
|
// only save the APIs that have changed
|
|
1381
|
-
await Promise.all(
|
|
1023
|
+
await Promise.all(otherAPIs.map(async ({ api, filePath }) => {
|
|
1382
1024
|
if (isEqual(api?.apiPb, this.apiFiles[filePath]?.apiPb)) {
|
|
1383
1025
|
return Promise.resolve();
|
|
1384
1026
|
}
|
|
1385
1027
|
await this.writeFile(filePath, yaml.stringify(api?.apiPb), "api");
|
|
1386
1028
|
this.emit("apiManualUpdate", {
|
|
1387
1029
|
api: this.createClientApi(api),
|
|
1388
|
-
|
|
1389
|
-
scopeId: scopeDef?.id ?? "",
|
|
1030
|
+
scopeId,
|
|
1390
1031
|
}, true);
|
|
1391
|
-
// TODO: Should I delete here?
|
|
1392
1032
|
}));
|
|
1393
1033
|
};
|
|
1394
1034
|
async removeApiData(filePath) {
|
|
@@ -1398,18 +1038,15 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1398
1038
|
}
|
|
1399
1039
|
delete this.apiFiles[filePath];
|
|
1400
1040
|
this.sourceTracker?.deleteApi({
|
|
1401
|
-
pageName: api.pageName,
|
|
1402
1041
|
apiName: api.apiPb.metadata.name,
|
|
1403
1042
|
});
|
|
1404
1043
|
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
1405
1044
|
await this.writeChanges(changes);
|
|
1406
|
-
const scopeId =
|
|
1045
|
+
const scopeId = getScopeIdFromName("App");
|
|
1407
1046
|
this.emit("apiManualDelete", {
|
|
1408
1047
|
api: {
|
|
1409
|
-
id:
|
|
1048
|
+
id: api.apiPb.metadata.name,
|
|
1410
1049
|
apiName: api.apiPb.metadata.name,
|
|
1411
|
-
// TODO(saksham): get pagename more defensively
|
|
1412
|
-
pageName: getPageName(filePath),
|
|
1413
1050
|
scopeId,
|
|
1414
1051
|
},
|
|
1415
1052
|
});
|
|
@@ -1428,7 +1065,7 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1428
1065
|
}
|
|
1429
1066
|
// Utilities for converting server API format to Client API format
|
|
1430
1067
|
// We internally save the API as the server does, but we return should always return it
|
|
1431
|
-
// to the client with an id
|
|
1068
|
+
// to the client with an id equal to the API name
|
|
1432
1069
|
createClientApi(api) {
|
|
1433
1070
|
return {
|
|
1434
1071
|
pageName: api.pageName,
|
|
@@ -1436,7 +1073,7 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1436
1073
|
...api.apiPb,
|
|
1437
1074
|
metadata: {
|
|
1438
1075
|
...api.apiPb.metadata,
|
|
1439
|
-
id:
|
|
1076
|
+
id: api.apiPb.metadata.name,
|
|
1440
1077
|
},
|
|
1441
1078
|
},
|
|
1442
1079
|
};
|
|
@@ -1448,7 +1085,6 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1448
1085
|
// We want to add the API entity to our scope, but we do not want to emit entity events, because
|
|
1449
1086
|
// the API update event handles this particular side effect.
|
|
1450
1087
|
const scopeId = await this.sourceTracker.addApi({
|
|
1451
|
-
pageName: api.pageName,
|
|
1452
1088
|
apiName: api.apiPb.metadata.name,
|
|
1453
1089
|
});
|
|
1454
1090
|
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
@@ -1473,23 +1109,15 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1473
1109
|
const parsedData = { apiPb: apiContent?.api };
|
|
1474
1110
|
if (!(yamlPath in this.apiFiles &&
|
|
1475
1111
|
isEqual(this.apiFiles[yamlPath]?.apiPb, parsedData.apiPb))) {
|
|
1476
|
-
const { updatedApi,
|
|
1112
|
+
const { updatedApi, isNewApi } = this.updateInternalApiData({
|
|
1477
1113
|
api: parsedData.apiPb,
|
|
1478
1114
|
stepPathMap: apiContent.stepPathMap,
|
|
1479
1115
|
}, yamlPath);
|
|
1480
1116
|
logger.info(`API changed: ${yamlPath}`);
|
|
1481
|
-
const
|
|
1482
|
-
if (!scopeDef) {
|
|
1483
|
-
logger.error(`Scope definition not found for API`);
|
|
1484
|
-
return;
|
|
1485
|
-
}
|
|
1486
|
-
if (isNewApi) {
|
|
1487
|
-
await this.addApiToScope(updatedApi);
|
|
1488
|
-
}
|
|
1117
|
+
const scopeId = getScopeIdFromName("App");
|
|
1489
1118
|
this.emit("apiManualUpdate", {
|
|
1490
1119
|
api: this.createClientApi(updatedApi),
|
|
1491
|
-
|
|
1492
|
-
scopeId: scopeDef.id,
|
|
1120
|
+
scopeId,
|
|
1493
1121
|
}, isNewApi);
|
|
1494
1122
|
}
|
|
1495
1123
|
else {
|
|
@@ -1505,21 +1133,15 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1505
1133
|
throw new Error("Root directory not set");
|
|
1506
1134
|
}
|
|
1507
1135
|
const { api: apiContents, stepPathMap } = content;
|
|
1508
|
-
const
|
|
1509
|
-
let scopeId = this.sourceTracker?.getScopeDefinitionForPage(pageName)?.id;
|
|
1510
|
-
if (!scopeId) {
|
|
1511
|
-
console.warn("Scope ID not found for API", apiContents.metadata.name);
|
|
1512
|
-
scopeId = "";
|
|
1513
|
-
}
|
|
1136
|
+
const scopeId = getScopeIdFromName("App");
|
|
1514
1137
|
const updatedApi = {
|
|
1515
1138
|
apiPb: yaml.parse(JSON.stringify(apiContents)),
|
|
1516
|
-
pageName,
|
|
1517
1139
|
stepPathMap,
|
|
1518
1140
|
scopeId,
|
|
1519
1141
|
};
|
|
1520
1142
|
const isNewApi = !this.apiFiles[path];
|
|
1521
1143
|
this.apiFiles[path] = updatedApi;
|
|
1522
|
-
return { updatedApi,
|
|
1144
|
+
return { updatedApi, isNewApi };
|
|
1523
1145
|
};
|
|
1524
1146
|
renameIdentifierInApis = async ({ elementId, oldName, newName, parentBinding, }) => {
|
|
1525
1147
|
const apisInScope = structuredClone(this.getApisInScope(elementId));
|
|
@@ -1537,15 +1159,12 @@ export const ${name} = ${name}Scope.entities;
|
|
|
1537
1159
|
return this.writeFile(filePath, yaml.stringify(api?.apiPb), "api");
|
|
1538
1160
|
}));
|
|
1539
1161
|
};
|
|
1540
|
-
getApisInScope = (
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
return Object.entries(this.apiFiles)
|
|
1547
|
-
.filter(([filePath]) => filePath.includes(pagePath))
|
|
1548
|
-
.map(([filePath, api]) => ({ api, filePath }));
|
|
1162
|
+
getApisInScope = (_elementId) => {
|
|
1163
|
+
// All APIs are now at app-level scope
|
|
1164
|
+
return Object.entries(this.apiFiles).map(([filePath, api]) => ({
|
|
1165
|
+
api,
|
|
1166
|
+
filePath,
|
|
1167
|
+
}));
|
|
1549
1168
|
};
|
|
1550
1169
|
}
|
|
1551
1170
|
// Add new mock implementation
|
|
@@ -1563,10 +1182,8 @@ export class MockFileSyncManager extends FileSystemManager {
|
|
|
1563
1182
|
else {
|
|
1564
1183
|
this.apiFiles[path] = {
|
|
1565
1184
|
apiPb: yaml.parse(content),
|
|
1566
|
-
pageName: getPageName(path),
|
|
1567
1185
|
stepPathMap: {},
|
|
1568
|
-
|
|
1569
|
-
scopeId: "",
|
|
1186
|
+
scopeId: getScopeIdFromName("App"),
|
|
1570
1187
|
};
|
|
1571
1188
|
}
|
|
1572
1189
|
// Notify subscribers
|
|
@@ -1585,16 +1202,16 @@ export class MockFileSyncManager extends FileSystemManager {
|
|
|
1585
1202
|
stepPathMap: {},
|
|
1586
1203
|
scopeId: payload.scopeId,
|
|
1587
1204
|
};
|
|
1588
|
-
const
|
|
1205
|
+
const scopeId = getScopeIdFromName("App");
|
|
1589
1206
|
const generationNumber = this.generationNumberSequence.next();
|
|
1590
1207
|
this.emit("apiUpdate", {
|
|
1591
1208
|
api: payload.api,
|
|
1592
|
-
scopeId
|
|
1209
|
+
scopeId,
|
|
1593
1210
|
});
|
|
1594
1211
|
return {
|
|
1595
1212
|
api: payload.api,
|
|
1596
1213
|
generationNumber,
|
|
1597
|
-
scopeId
|
|
1214
|
+
scopeId,
|
|
1598
1215
|
};
|
|
1599
1216
|
};
|
|
1600
1217
|
}
|