openxiangda 1.0.264 → 2.0.0-alpha.2
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/README.md +11 -666
- package/bin/run.js +11 -0
- package/dist/browser/AuthoritativeSelector.d.ts +37 -0
- package/dist/browser/AuthoritativeSelector.d.ts.map +1 -0
- package/dist/browser/AuthoritativeSelector.js +357 -0
- package/dist/browser/AuthoritativeSelector.js.map +1 -0
- package/dist/browser/FilePreviewPage.d.ts +2 -0
- package/dist/browser/FilePreviewPage.d.ts.map +1 -0
- package/dist/browser/FilePreviewPage.js +191 -0
- package/dist/browser/FilePreviewPage.js.map +1 -0
- package/dist/browser/Shell.d.ts +6 -0
- package/dist/browser/Shell.d.ts.map +1 -0
- package/dist/browser/Shell.js +198 -0
- package/dist/browser/Shell.js.map +1 -0
- package/dist/browser/appearance.d.ts +12 -0
- package/dist/browser/appearance.d.ts.map +1 -0
- package/dist/browser/appearance.js +100 -0
- package/dist/browser/appearance.js.map +1 -0
- package/dist/browser/application.d.ts +8 -0
- package/dist/browser/application.d.ts.map +1 -0
- package/dist/browser/application.js +42 -0
- package/dist/browser/application.js.map +1 -0
- package/dist/browser/components/platform-fields/AddressField.d.ts +12 -0
- package/dist/browser/components/platform-fields/AddressField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/AddressField.js +179 -0
- package/dist/browser/components/platform-fields/AddressField.js.map +1 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.d.ts +9 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.js +164 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.js.map +1 -0
- package/dist/browser/components/platform-fields/CascadeField.d.ts +13 -0
- package/dist/browser/components/platform-fields/CascadeField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/CascadeField.js +14 -0
- package/dist/browser/components/platform-fields/CascadeField.js.map +1 -0
- package/dist/browser/components/platform-fields/DateTimeField.d.ts +16 -0
- package/dist/browser/components/platform-fields/DateTimeField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/DateTimeField.js +51 -0
- package/dist/browser/components/platform-fields/DateTimeField.js.map +1 -0
- package/dist/browser/components/platform-fields/JsonField.d.ts +11 -0
- package/dist/browser/components/platform-fields/JsonField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/JsonField.js +40 -0
- package/dist/browser/components/platform-fields/JsonField.js.map +1 -0
- package/dist/browser/components/platform-fields/LocationField.d.ts +11 -0
- package/dist/browser/components/platform-fields/LocationField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/LocationField.js +73 -0
- package/dist/browser/components/platform-fields/LocationField.js.map +1 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.d.ts +12 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.js +269 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.js.map +1 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts +12 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.js +22 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.js.map +1 -0
- package/dist/browser/components/platform-fields/RichTextField.d.ts +14 -0
- package/dist/browser/components/platform-fields/RichTextField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/RichTextField.js +214 -0
- package/dist/browser/components/platform-fields/RichTextField.js.map +1 -0
- package/dist/browser/components/platform-fields/SignatureField.d.ts +15 -0
- package/dist/browser/components/platform-fields/SignatureField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/SignatureField.js +179 -0
- package/dist/browser/components/platform-fields/SignatureField.js.map +1 -0
- package/dist/browser/components/platform-fields/SubtableField.d.ts +18 -0
- package/dist/browser/components/platform-fields/SubtableField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/SubtableField.js +236 -0
- package/dist/browser/components/platform-fields/SubtableField.js.map +1 -0
- package/dist/browser/components/platform-fields/address-value.d.ts +13 -0
- package/dist/browser/components/platform-fields/address-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/address-value.js +70 -0
- package/dist/browser/components/platform-fields/address-value.js.map +1 -0
- package/dist/browser/components/platform-fields/cascade-value.d.ts +6 -0
- package/dist/browser/components/platform-fields/cascade-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/cascade-value.js +47 -0
- package/dist/browser/components/platform-fields/cascade-value.js.map +1 -0
- package/dist/browser/components/platform-fields/directory-value.d.ts +7 -0
- package/dist/browser/components/platform-fields/directory-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/directory-value.js +35 -0
- package/dist/browser/components/platform-fields/directory-value.js.map +1 -0
- package/dist/browser/components/platform-fields/field-form-codec.d.ts +10 -0
- package/dist/browser/components/platform-fields/field-form-codec.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/field-form-codec.js +82 -0
- package/dist/browser/components/platform-fields/field-form-codec.js.map +1 -0
- package/dist/browser/components/platform-fields/location-value.d.ts +20 -0
- package/dist/browser/components/platform-fields/location-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/location-value.js +57 -0
- package/dist/browser/components/platform-fields/location-value.js.map +1 -0
- package/dist/browser/components/platform-fields/resource-query.d.ts +14 -0
- package/dist/browser/components/platform-fields/resource-query.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/resource-query.js +102 -0
- package/dist/browser/components/platform-fields/resource-query.js.map +1 -0
- package/dist/browser/components/platform-fields/rich-text-value.d.ts +12 -0
- package/dist/browser/components/platform-fields/rich-text-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/rich-text-value.js +83 -0
- package/dist/browser/components/platform-fields/rich-text-value.js.map +1 -0
- package/dist/browser/components/platform-fields/subtable-value.d.ts +31 -0
- package/dist/browser/components/platform-fields/subtable-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/subtable-value.js +120 -0
- package/dist/browser/components/platform-fields/subtable-value.js.map +1 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.d.ts +8 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.d.ts.map +1 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.js +580 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.js.map +1 -0
- package/dist/browser/components/resource/ResourceBatchActions.d.ts +25 -0
- package/dist/browser/components/resource/ResourceBatchActions.d.ts.map +1 -0
- package/dist/browser/components/resource/ResourceBatchActions.js +168 -0
- package/dist/browser/components/resource/ResourceBatchActions.js.map +1 -0
- package/dist/browser/components/resource/StandardResourcePages.d.ts +57 -0
- package/dist/browser/components/resource/StandardResourcePages.d.ts.map +1 -0
- package/dist/browser/components/resource/StandardResourcePages.js +89 -0
- package/dist/browser/components/resource/StandardResourcePages.js.map +1 -0
- package/dist/browser/components/resource/SurfaceFields.d.ts +88 -0
- package/dist/browser/components/resource/SurfaceFields.d.ts.map +1 -0
- package/dist/browser/components/resource/SurfaceFields.js +497 -0
- package/dist/browser/components/resource/SurfaceFields.js.map +1 -0
- package/dist/browser/components/resource/generated-resource-definition.d.ts +19 -0
- package/dist/browser/components/resource/generated-resource-definition.d.ts.map +1 -0
- package/dist/browser/components/resource/generated-resource-definition.js +2 -0
- package/dist/browser/components/resource/generated-resource-definition.js.map +1 -0
- package/dist/browser/components/resource/resource-import.d.ts +15 -0
- package/dist/browser/components/resource/resource-import.d.ts.map +1 -0
- package/dist/browser/components/resource/resource-import.js +197 -0
- package/dist/browser/components/resource/resource-import.js.map +1 -0
- package/dist/browser/data-provider.d.ts +4 -0
- package/dist/browser/data-provider.d.ts.map +1 -0
- package/dist/browser/data-provider.js +45 -0
- package/dist/browser/data-provider.js.map +1 -0
- package/dist/browser/platform-client.d.ts +81 -0
- package/dist/browser/platform-client.d.ts.map +1 -0
- package/dist/browser/platform-client.js +422 -0
- package/dist/browser/platform-client.js.map +1 -0
- package/dist/browser/resource-definitions.d.ts +8 -0
- package/dist/browser/resource-definitions.d.ts.map +1 -0
- package/dist/browser/resource-definitions.js +14 -0
- package/dist/browser/resource-definitions.js.map +1 -0
- package/dist/browser/runtime-meta.d.ts +22 -0
- package/dist/browser/runtime-meta.d.ts.map +1 -0
- package/dist/browser/runtime-meta.js +79 -0
- package/dist/browser/runtime-meta.js.map +1 -0
- package/dist/browser/runtime.d.ts +13 -0
- package/dist/browser/runtime.d.ts.map +1 -0
- package/dist/browser/runtime.js +47 -0
- package/dist/browser/runtime.js.map +1 -0
- package/dist/browser/styles.css +1941 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/core.d.ts +6 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +4 -0
- package/dist/core.js.map +1 -0
- package/dist/field-kit.d.ts +22 -0
- package/dist/field-kit.d.ts.map +1 -0
- package/dist/field-kit.js +22 -0
- package/dist/field-kit.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/nest.d.ts +10 -0
- package/dist/nest.d.ts.map +1 -0
- package/dist/nest.js +9 -0
- package/dist/nest.js.map +1 -0
- package/dist/react.d.ts +12 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +11 -0
- package/dist/react.js.map +1 -0
- package/dist/testing.d.ts +4 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +4 -0
- package/dist/testing.js.map +1 -0
- package/package.json +95 -200
- package/skills/manifest.json +10 -0
- package/skills/openxiangda-v2/SKILL.md +55 -0
- package/skills/openxiangda-v2/references/architecture.md +7 -0
- package/skills/openxiangda-v2/references/backend.md +116 -0
- package/skills/openxiangda-v2/references/data-authz.md +93 -0
- package/skills/openxiangda-v2/references/delivery.md +11 -0
- package/skills/openxiangda-v2/references/discovery.md +15 -0
- package/skills/openxiangda-v2/references/frontend.md +10 -0
- package/skills/openxiangda-v2/references/testing.md +16 -0
- package/skills/openxiangda-v2/references/workflow-notification.md +69 -0
- package/skills/openxiangda-v2/references/workspace.md +21 -0
- package/bin/openxiangda.js +0 -26
- package/lib/app-function-invoke.js +0 -28
- package/lib/application-environments.js +0 -1134
- package/lib/change-baseline.js +0 -1359
- package/lib/cli.js +0 -31084
- package/lib/config.js +0 -450
- package/lib/content-cache.js +0 -97
- package/lib/delivery-v2-cli.js +0 -329
- package/lib/delivery-v2-executor.js +0 -1703
- package/lib/delivery-v2-package.js +0 -1176
- package/lib/dependency-capsule.js +0 -246
- package/lib/design-gates.js +0 -668
- package/lib/design-review.js +0 -220
- package/lib/developer-center.js +0 -160
- package/lib/form-field-contract.js +0 -79
- package/lib/form-schema-loader.js +0 -181
- package/lib/git-remote-identity.js +0 -89
- package/lib/http.js +0 -196
- package/lib/integration-bundle.js +0 -225
- package/lib/js-code-build.js +0 -175
- package/lib/open-api.js +0 -256
- package/lib/policy.js +0 -137
- package/lib/publish-context.js +0 -98
- package/lib/publish-lease-heartbeat.js +0 -182
- package/lib/publish-lease.js +0 -221
- package/lib/release-error-classification.js +0 -41
- package/lib/release-explain.js +0 -75
- package/lib/release-mainline.js +0 -654
- package/lib/release-plan.js +0 -550
- package/lib/release-telemetry.js +0 -182
- package/lib/resource-binding-contract.js +0 -210
- package/lib/role-resolution.js +0 -57
- package/lib/runtime-lineage.js +0 -326
- package/lib/sdd.js +0 -3306
- package/lib/skills.js +0 -453
- package/lib/source-dependencies.js +0 -921
- package/lib/task-status.js +0 -330
- package/lib/utils.js +0 -178
- package/lib/workspace-bootstrap.js +0 -268
- package/lib/workspace-init.js +0 -202
- package/lib/worktree-cleanup.js +0 -631
- package/lib/worktree-owner.js +0 -354
- package/openxiangda-skills/SKILL.md +0 -226
- package/openxiangda-skills/references/architecture-design.md +0 -409
- package/openxiangda-skills/references/architecture-patterns.md +0 -264
- package/openxiangda-skills/references/automation-v3.md +0 -349
- package/openxiangda-skills/references/best-practices.md +0 -272
- package/openxiangda-skills/references/component-guide.md +0 -287
- package/openxiangda-skills/references/connector-resources.md +0 -80
- package/openxiangda-skills/references/data-views.md +0 -360
- package/openxiangda-skills/references/forms/component-registry.md +0 -90
- package/openxiangda-skills/references/forms/form-schema.md +0 -146
- package/openxiangda-skills/references/forms/layout-and-rules.md +0 -24
- package/openxiangda-skills/references/notifications.md +0 -227
- package/openxiangda-skills/references/openxiangda-api.md +0 -971
- package/openxiangda-skills/references/pages/app-shell.md +0 -66
- package/openxiangda-skills/references/pages/page-sdk.md +0 -401
- package/openxiangda-skills/references/pages/publish-flow.md +0 -84
- package/openxiangda-skills/references/pages/workspace-structure.md +0 -41
- package/openxiangda-skills/references/permission-design-patterns.md +0 -313
- package/openxiangda-skills/references/permissions-settings.md +0 -468
- package/openxiangda-skills/references/platform-data-model.md +0 -340
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +0 -936
- package/openxiangda-skills/references/school-contact-relations.md +0 -224
- package/openxiangda-skills/references/style-system.md +0 -218
- package/openxiangda-skills/references/troubleshooting.md +0 -271
- package/openxiangda-skills/references/workflow-v3.md +0 -441
- package/openxiangda-skills/references/workspace-state.md +0 -115
- package/openxiangda-skills/skills/openxiangda-app/SKILL.md +0 -118
- package/openxiangda-skills/skills/openxiangda-architecture-design/SKILL.md +0 -137
- package/openxiangda-skills/skills/openxiangda-core/SKILL.md +0 -222
- package/openxiangda-skills/skills/openxiangda-form/SKILL.md +0 -184
- package/openxiangda-skills/skills/openxiangda-inspect/SKILL.md +0 -63
- package/openxiangda-skills/skills/openxiangda-open-api/SKILL.md +0 -57
- package/openxiangda-skills/skills/openxiangda-open-api/agents/openai.yaml +0 -4
- package/openxiangda-skills/skills/openxiangda-open-api/references/backend-authentication.md +0 -63
- package/openxiangda-skills/skills/openxiangda-open-api/references/dingtalk-api.openapi.json +0 -15653
- package/openxiangda-skills/skills/openxiangda-page/SKILL.md +0 -154
- package/openxiangda-skills/skills/openxiangda-permission-settings/SKILL.md +0 -209
- package/openxiangda-skills/skills/openxiangda-workflow-automation/SKILL.md +0 -201
- package/packages/sdk/bin/lowcode-workspace.mjs +0 -4
- package/packages/sdk/dist/ProcessPreview-DSUIJi5V.d.mts +0 -1292
- package/packages/sdk/dist/ProcessPreview-DSUIJi5V.d.ts +0 -1292
- package/packages/sdk/dist/build/index.cjs +0 -1
- package/packages/sdk/dist/build/index.d.mts +0 -60
- package/packages/sdk/dist/build/index.d.ts +0 -60
- package/packages/sdk/dist/build/index.mjs +0 -1
- package/packages/sdk/dist/components/index.cjs +0 -148
- package/packages/sdk/dist/components/index.d.mts +0 -970
- package/packages/sdk/dist/components/index.d.ts +0 -970
- package/packages/sdk/dist/components/index.mjs +0 -148
- package/packages/sdk/dist/dataManagementApi-Ro9itwm8.d.ts +0 -142
- package/packages/sdk/dist/dataManagementApi-p_HOhQnA.d.mts +0 -142
- package/packages/sdk/dist/runtime/index.cjs +0 -148
- package/packages/sdk/dist/runtime/index.d.mts +0 -171
- package/packages/sdk/dist/runtime/index.d.ts +0 -171
- package/packages/sdk/dist/runtime/index.mjs +0 -148
- package/packages/sdk/dist/runtime/react.cjs +0 -148
- package/packages/sdk/dist/runtime/react.d.mts +0 -3202
- package/packages/sdk/dist/runtime/react.d.ts +0 -3202
- package/packages/sdk/dist/runtime/react.mjs +0 -148
- package/packages/sdk/dist/styles/antd-theme.cjs +0 -1
- package/packages/sdk/dist/styles/antd-theme.d.mts +0 -6
- package/packages/sdk/dist/styles/antd-theme.d.ts +0 -6
- package/packages/sdk/dist/styles/antd-theme.mjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.cjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.d.mts +0 -74
- package/packages/sdk/dist/styles/tailwind-preset.d.ts +0 -74
- package/packages/sdk/dist/styles/tailwind-preset.mjs +0 -1
- package/packages/sdk/dist/styles/tokens.css +0 -74
- package/packages/sdk/dist/workflow/index.cjs +0 -3
- package/packages/sdk/dist/workflow/index.d.mts +0 -291
- package/packages/sdk/dist/workflow/index.d.ts +0 -291
- package/packages/sdk/dist/workflow/index.mjs +0 -3
- package/packages/sdk/source/admin-list/AdminList.tsx +0 -1734
- package/packages/sdk/source/admin-list/README.md +0 -12
- package/packages/sdk/source/admin-list/dataSources.ts +0 -345
- package/packages/sdk/source/admin-list/index.ts +0 -42
- package/packages/sdk/source/admin-list/preferences.ts +0 -174
- package/packages/sdk/source/admin-list/types.ts +0 -273
- package/packages/sdk/src/build-source/README.md +0 -9
- package/packages/sdk/src/build-source/bin/lowcode-workspace.mjs +0 -7
- package/packages/sdk/src/build-source/package.json +0 -34
- package/packages/sdk/src/build-source/scripts/build-forms.mjs +0 -1129
- package/packages/sdk/src/build-source/scripts/build-pages.mjs +0 -897
- package/packages/sdk/src/build-source/scripts/build-workspace.mjs +0 -89
- package/packages/sdk/src/build-source/scripts/publish-all.mjs +0 -190
- package/packages/sdk/src/build-source/scripts/publish-oss.mjs +0 -144
- package/packages/sdk/src/build-source/scripts/register-bundle.mjs +0 -1
- package/packages/sdk/src/build-source/scripts/register.mjs +0 -362
- package/packages/sdk/src/build-source/scripts/sync-schema.mjs +0 -381
- package/packages/sdk/src/build-source/scripts/utils/form-api.mjs +0 -1058
- package/packages/sdk/src/build-source/scripts/utils/form-runtime-assets.mjs +0 -57
- package/packages/sdk/src/build-source/scripts/utils/incremental.mjs +0 -348
- package/packages/sdk/src/build-source/scripts/utils/load-config.mjs +0 -331
- package/packages/sdk/src/build-source/scripts/utils/mime-types.mjs +0 -70
- package/packages/sdk/src/build-source/scripts/utils/namespace-css.mjs +0 -77
- package/packages/sdk/src/build-source/scripts/utils/oss-client.mjs +0 -128
- package/packages/sdk/src/build-source/scripts/utils/pages.mjs +0 -150
- package/packages/sdk/src/build-source/scripts/utils/progress.mjs +0 -57
- package/packages/sdk/src/build-source/scripts/utils/publish-oss-patterns.mjs +0 -20
- package/packages/sdk/src/build-source/scripts/utils/register-payload.mjs +0 -90
- package/packages/sdk/src/build-source/scripts/utils/runtime-css-check.mjs +0 -44
- package/packages/sdk/src/build-source/scripts/utils/schema-transform.mjs +0 -142
- package/packages/sdk/src/build-source/scripts/utils/static-assets.mjs +0 -165
- package/packages/sdk/src/build-source/scripts/utils/tailwind-config.mjs +0 -283
- package/packages/sdk/src/build-source/scripts/utils/tailwind-token-warnings.mjs +0 -146
- package/packages/sdk/src/build-source/scripts/utils/workspace-style-entry.mjs +0 -29
- package/packages/sdk/src/build-source/src/cli.mjs +0 -735
- package/policy/openxiangda-policy.json +0 -72
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-form.mdc +0 -24
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-page.mdc +0 -25
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-resources.mdc +0 -32
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-workflow-automation.mdc +0 -26
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda.mdc +0 -68
- package/templates/openxiangda-react-spa/.env.example +0 -4
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-form.md +0 -37
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-page.md +0 -29
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-resources.md +0 -32
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-workflow-automation.md +0 -34
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda.md +0 -66
- package/templates/openxiangda-react-spa/AGENTS.md +0 -192
- package/templates/openxiangda-react-spa/DELIVERY.md +0 -43
- package/templates/openxiangda-react-spa/app-workspace.config.ts +0 -50
- package/templates/openxiangda-react-spa/index.html +0 -12
- package/templates/openxiangda-react-spa/package.json +0 -53
- package/templates/openxiangda-react-spa/postcss.config.cjs +0 -6
- package/templates/openxiangda-react-spa/scripts/build-js-code.mjs +0 -600
- package/templates/openxiangda-react-spa/scripts/deploy.mjs +0 -18
- package/templates/openxiangda-react-spa/scripts/guard-publish.mjs +0 -21
- package/templates/openxiangda-react-spa/src/app/navigation.ts +0 -73
- package/templates/openxiangda-react-spa/src/app/router.tsx +0 -146
- package/templates/openxiangda-react-spa/src/app/starter-content.ts +0 -144
- package/templates/openxiangda-react-spa/src/forms/.gitkeep +0 -1
- package/templates/openxiangda-react-spa/src/layouts/AdminShell.tsx +0 -570
- package/templates/openxiangda-react-spa/src/main.tsx +0 -21
- package/templates/openxiangda-react-spa/src/pages/admin/AdminDashboardPage.tsx +0 -170
- package/templates/openxiangda-react-spa/src/pages/admin/LoginLogPage.tsx +0 -425
- package/templates/openxiangda-react-spa/src/pages/defaults/DataRoutePage.tsx +0 -36
- package/templates/openxiangda-react-spa/src/pages/defaults/FilePreviewRoutePage.tsx +0 -65
- package/templates/openxiangda-react-spa/src/pages/defaults/FormRoutePage.tsx +0 -235
- package/templates/openxiangda-react-spa/src/pages/public/PublicRegisterPage.tsx +0 -15
- package/templates/openxiangda-react-spa/src/pages/states/NotFoundPage.tsx +0 -31
- package/templates/openxiangda-react-spa/src/resources/menus/menus.json +0 -22
- package/templates/openxiangda-react-spa/src/resources/permissions/page-groups/app-admin.json +0 -8
- package/templates/openxiangda-react-spa/src/resources/permissions/page-groups/public-visitor.json +0 -8
- package/templates/openxiangda-react-spa/src/resources/public-access/public-register.json +0 -14
- package/templates/openxiangda-react-spa/src/resources/roles/roles.json +0 -15
- package/templates/openxiangda-react-spa/src/resources/routes/public-register.json +0 -8
- package/templates/openxiangda-react-spa/src/runtime/default-page-overrides.tsx +0 -35
- package/templates/openxiangda-react-spa/src/runtime/default-routes.ts +0 -16
- package/templates/openxiangda-react-spa/src/shared/form-schema.ts +0 -135
- package/templates/openxiangda-react-spa/src/shared/mac-admin.tsx +0 -651
- package/templates/openxiangda-react-spa/src/shared/ui.tsx +0 -22
- package/templates/openxiangda-react-spa/src/styles/index.css +0 -105
- package/templates/openxiangda-react-spa/tailwind.config.cjs +0 -37
- package/templates/openxiangda-react-spa/tsconfig.app.json +0 -36
- package/templates/openxiangda-react-spa/tsconfig.js-code-nodes.json +0 -19
- package/templates/openxiangda-react-spa/tsconfig.json +0 -7
- package/templates/openxiangda-react-spa/tsconfig.node.json +0 -10
- package/templates/openxiangda-react-spa/vite.config.ts +0 -209
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-form.mdc +0 -24
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-page.mdc +0 -21
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-resources.mdc +0 -40
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-workflow-automation.mdc +0 -21
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda.mdc +0 -81
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-form.md +0 -38
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-page.md +0 -39
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-resources.md +0 -59
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-workflow-automation.md +0 -46
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda.md +0 -82
- package/templates/sy-lowcode-app-workspace/AGENTS.md +0 -158
- package/templates/sy-lowcode-app-workspace/DELIVERY.md +0 -43
- package/templates/sy-lowcode-app-workspace/app-workspace.config.ts +0 -51
- package/templates/sy-lowcode-app-workspace/examples/best-practices/README.md +0 -43
- package/templates/sy-lowcode-app-workspace/examples/best-practices/access-governance.md +0 -239
- package/templates/sy-lowcode-app-workspace/examples/best-practices/catalog.json +0 -99
- package/templates/sy-lowcode-app-workspace/examples/best-practices/decision-guide.md +0 -94
- package/templates/sy-lowcode-app-workspace/examples/best-practices/design-style.md +0 -91
- package/templates/sy-lowcode-app-workspace/examples/best-practices/module-structure.md +0 -48
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/index.ts +0 -2
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.test.ts +0 -52
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.ts +0 -37
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/types.ts +0 -19
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/index.ts +0 -4
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/permissions.test.ts +0 -42
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/permissions.ts +0 -25
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/state-machine.test.ts +0 -63
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/state-machine.ts +0 -73
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/ticket-query.test.ts +0 -34
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/ticket-query.ts +0 -73
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/types.ts +0 -66
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/schema.ts +0 -109
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/customer-profile/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/customer-profile/schema.ts +0 -92
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/schema.ts +0 -153
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/ticket-action-log/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/ticket-action-log/schema.ts +0 -65
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/js-code-nodes/daily_ticket_digest/index.ts +0 -44
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/js-code-nodes/sync_roles_to_platform/index.ts +0 -33
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/GlassHomeDashboard.tsx +0 -232
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/styles.css +0 -196
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/WorkbenchPage.tsx +0 -36
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/components/ConfigPanel.tsx +0 -34
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/components/PreviewPanel.tsx +0 -17
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/page.config.ts +0 -9
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/reducer.ts +0 -29
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/styles.css +0 -24
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/MintAnalyticsDashboard.tsx +0 -279
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/styles.css +0 -163
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/MobilePortalShell.tsx +0 -31
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/modules/MobileHome.tsx +0 -13
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/routes.ts +0 -13
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/styles.css +0 -11
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/OpsMonitorDashboard.tsx +0 -306
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/styles.css +0 -248
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/PcPortalShell.tsx +0 -35
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/components/PortalMetric.tsx +0 -11
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/modules/HomeModule.tsx +0 -25
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/modules/TicketsModule.tsx +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/routes.ts +0 -19
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/styles.css +0 -35
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/TicketOpsPage.tsx +0 -105
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketActionTimeline.tsx +0 -22
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketDetailDrawer.tsx +0 -44
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketTableActions.tsx +0 -57
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/page.config.ts +0 -9
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/styles.css +0 -35
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/WorkOrderListDrawerPage.tsx +0 -371
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/styles.css +0 -182
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/automations/daily-ticket-digest/automation.json +0 -25
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/automations/daily-ticket-digest/trigger.json +0 -9
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/notifications/daily-ticket-digest.json +0 -24
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/permissions/form-groups/service-ticket-college.json +0 -21
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/permissions/roles.json +0 -17
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/workflows/expense-approval-workflow.json +0 -48
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/ConfirmAction.tsx +0 -22
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/QueryState.tsx +0 -37
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/StatusTag.tsx +0 -20
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/DashboardPrimitives.tsx +0 -832
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/chartOptions.ts +0 -140
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/sampleData.ts +0 -466
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/styles.css +0 -874
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/types.ts +0 -150
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/hooks/useTicketOps.ts +0 -96
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/services/role-governance.ts +0 -48
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/services/service-ticket.ts +0 -113
- package/templates/sy-lowcode-app-workspace/examples/forms/customer/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/forms/customer/schema.ts +0 -36
- package/templates/sy-lowcode-app-workspace/index.html +0 -12
- package/templates/sy-lowcode-app-workspace/package.json +0 -58
- package/templates/sy-lowcode-app-workspace/postcss.config.cjs +0 -9
- package/templates/sy-lowcode-app-workspace/scripts/build-js-code.mjs +0 -600
- package/templates/sy-lowcode-app-workspace/scripts/guard-publish.mjs +0 -29
- package/templates/sy-lowcode-app-workspace/src/dev/App.tsx +0 -820
- package/templates/sy-lowcode-app-workspace/src/forms/.gitkeep +0 -1
- package/templates/sy-lowcode-app-workspace/src/forms/README.md +0 -52
- package/templates/sy-lowcode-app-workspace/src/index.css +0 -26
- package/templates/sy-lowcode-app-workspace/src/js-code-nodes/.gitkeep +0 -1
- package/templates/sy-lowcode-app-workspace/src/js-code-nodes/types.d.ts +0 -3
- package/templates/sy-lowcode-app-workspace/src/main.tsx +0 -29
- package/templates/sy-lowcode-app-workspace/src/pages/.gitkeep +0 -1
- package/templates/sy-lowcode-app-workspace/src/runtime/builtin-overrides.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/src/shared/form-schema.ts +0 -135
- package/templates/sy-lowcode-app-workspace/src/types/app-workspace.types.ts +0 -88
- package/templates/sy-lowcode-app-workspace/tailwind.config.cjs +0 -31
- package/templates/sy-lowcode-app-workspace/tsconfig.app.json +0 -40
- package/templates/sy-lowcode-app-workspace/tsconfig.examples.json +0 -24
- package/templates/sy-lowcode-app-workspace/tsconfig.js-code-nodes.json +0 -19
- package/templates/sy-lowcode-app-workspace/tsconfig.json +0 -7
- package/templates/sy-lowcode-app-workspace/tsconfig.node.json +0 -10
- package/templates/sy-lowcode-app-workspace/vite.config.ts +0 -85
- package/v2/README.md +0 -35
- package/v2/skills/manifest.json +0 -45
- package/v2/skills/openxiangda-v1-maintenance/SKILL.md +0 -21
- package/v2/skills/openxiangda-v1-maintenance/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2/SKILL.md +0 -38
- package/v2/skills/openxiangda-v2-architecture/SKILL.md +0 -29
- package/v2/skills/openxiangda-v2-architecture/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-backend/SKILL.md +0 -28
- package/v2/skills/openxiangda-v2-backend/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-data-authz/SKILL.md +0 -28
- package/v2/skills/openxiangda-v2-data-authz/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-delivery/SKILL.md +0 -30
- package/v2/skills/openxiangda-v2-delivery/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-frontend/SKILL.md +0 -21
- package/v2/skills/openxiangda-v2-frontend/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-workflow-events/SKILL.md +0 -28
- package/v2/skills/openxiangda-v2-workflow-events/agents/openai.yaml +0 -4
- /package/{v2/skills → skills}/openxiangda-v2/agents/openai.yaml +0 -0
|
@@ -1,1129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* build-forms.mjs - 构建单个或全部表单页面
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import crypto from "node:crypto";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import { createRequire } from "node:module";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
-
import { gzipSync } from "node:zlib";
|
|
11
|
-
import { build } from "vite";
|
|
12
|
-
import { loadConfig, rootDir } from "./utils/load-config.mjs";
|
|
13
|
-
import {
|
|
14
|
-
cleanBuildCache,
|
|
15
|
-
commitIncrementalBuild,
|
|
16
|
-
normalizeOnly,
|
|
17
|
-
planIncrementalBuild,
|
|
18
|
-
printPlan,
|
|
19
|
-
} from "./utils/incremental.mjs";
|
|
20
|
-
import { createNamespaceCssPlugin } from "./utils/namespace-css.mjs";
|
|
21
|
-
import { validateRuntimeCssFile } from "./utils/runtime-css-check.mjs";
|
|
22
|
-
import {
|
|
23
|
-
extractLargeDataUrlAssets,
|
|
24
|
-
formatExtractedAssetSummary,
|
|
25
|
-
} from "./utils/static-assets.mjs";
|
|
26
|
-
import { warnShadcnTailwindTokens } from "./utils/tailwind-token-warnings.mjs";
|
|
27
|
-
import {
|
|
28
|
-
createWorkspaceStyleImport,
|
|
29
|
-
listWorkspaceStyleEntryPaths,
|
|
30
|
-
} from "./utils/workspace-style-entry.mjs";
|
|
31
|
-
|
|
32
|
-
process.env.NODE_ENV = "production";
|
|
33
|
-
process.env.BABEL_ENV = "production";
|
|
34
|
-
|
|
35
|
-
const require = createRequire(import.meta.url);
|
|
36
|
-
const formsDir = path.join(rootDir, "src/forms");
|
|
37
|
-
const distDir = path.join(rootDir, "dist/forms");
|
|
38
|
-
const runtimeDistDir = path.join(rootDir, "dist/form-runtime");
|
|
39
|
-
const tmpDir = path.join(rootDir, ".tmp");
|
|
40
|
-
const runtimeVersionPlaceholder = "__SY_FORM_RUNTIME_VERSION__";
|
|
41
|
-
const runtimeCacheFileName = "build-cache.json";
|
|
42
|
-
const portalContainerResolverGlobal = "__OPENXIANGDA_GET_PORTAL_CONTAINER__";
|
|
43
|
-
let workspaceConfigPromise = null;
|
|
44
|
-
|
|
45
|
-
const runtimePackages = [
|
|
46
|
-
"react",
|
|
47
|
-
"react-dom",
|
|
48
|
-
"@ant-design/cssinjs",
|
|
49
|
-
"antd",
|
|
50
|
-
"antd-mobile",
|
|
51
|
-
"openxiangda",
|
|
52
|
-
"@tiptap/react",
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
function formatBytes(bytes) {
|
|
56
|
-
if (!Number.isFinite(bytes)) return "-";
|
|
57
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
58
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
|
|
59
|
-
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function formatDuration(startTime) {
|
|
63
|
-
return `${((Date.now() - startTime) / 1000).toFixed(2)}s`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function fileSizeLabel(filePath) {
|
|
67
|
-
if (!fs.existsSync(filePath)) return "未生成";
|
|
68
|
-
return formatBytes(fs.statSync(filePath).size);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function fileGzipSizeLabel(filePath) {
|
|
72
|
-
if (!fs.existsSync(filePath)) return "未生成";
|
|
73
|
-
return formatBytes(gzipSync(fs.readFileSync(filePath)).length);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function readTextIfExists(filePath) {
|
|
77
|
-
if (!fs.existsSync(filePath)) return "";
|
|
78
|
-
return fs.readFileSync(filePath, "utf-8");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function normalizeCssIsolation(value) {
|
|
82
|
-
if (value === "namespace" || value === "shadow") return value;
|
|
83
|
-
return "none";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function usesNamespaceCss(cssIsolation) {
|
|
87
|
-
return cssIsolation === "namespace" || cssIsolation === "shadow";
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function getWorkspaceConfig() {
|
|
91
|
-
if (!workspaceConfigPromise) workspaceConfigPromise = loadConfig();
|
|
92
|
-
return workspaceConfigPromise;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function readPackageVersion(packageName) {
|
|
96
|
-
try {
|
|
97
|
-
let current = path.dirname(require.resolve(packageName));
|
|
98
|
-
while (current && current !== path.dirname(current)) {
|
|
99
|
-
const packageJsonPath = path.join(current, "package.json");
|
|
100
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
101
|
-
return (
|
|
102
|
-
JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")).version ||
|
|
103
|
-
"unknown"
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
current = path.dirname(current);
|
|
107
|
-
}
|
|
108
|
-
return "unknown";
|
|
109
|
-
} catch {
|
|
110
|
-
return "missing";
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function createRuntimeInputHash(runtimeEntryContent, cssIsolation) {
|
|
115
|
-
const hash = crypto.createHash("sha256");
|
|
116
|
-
const configFiles = [
|
|
117
|
-
...listWorkspaceStyleEntryPaths(rootDir),
|
|
118
|
-
path.join(rootDir, "app-workspace.config.ts"),
|
|
119
|
-
path.join(rootDir, "tailwind.config.cjs"),
|
|
120
|
-
path.join(rootDir, "postcss.config.cjs"),
|
|
121
|
-
fileURLToPath(import.meta.url),
|
|
122
|
-
];
|
|
123
|
-
const packageVersions = runtimePackages.reduce((result, packageName) => {
|
|
124
|
-
result[packageName] = readPackageVersion(packageName);
|
|
125
|
-
return result;
|
|
126
|
-
}, {});
|
|
127
|
-
|
|
128
|
-
hash.update("sy-form-runtime-v2-input");
|
|
129
|
-
hash.update(runtimeEntryContent);
|
|
130
|
-
hash.update(normalizeCssIsolation(cssIsolation));
|
|
131
|
-
hash.update(JSON.stringify(packageVersions));
|
|
132
|
-
configFiles.forEach((filePath) => {
|
|
133
|
-
hash.update(filePath);
|
|
134
|
-
hash.update(readTextIfExists(filePath));
|
|
135
|
-
});
|
|
136
|
-
return hash.digest("hex");
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async function createCssOptions(cssIsolation = "none") {
|
|
140
|
-
const tailwindcssModule = await import("tailwindcss");
|
|
141
|
-
const autoprefixerModule = await import("autoprefixer");
|
|
142
|
-
const tailwindcss = tailwindcssModule.default ?? tailwindcssModule;
|
|
143
|
-
const autoprefixer = autoprefixerModule.default ?? autoprefixerModule;
|
|
144
|
-
const plugins = [
|
|
145
|
-
tailwindcss({ config: path.join(rootDir, "tailwind.config.cjs") }),
|
|
146
|
-
];
|
|
147
|
-
if (usesNamespaceCss(normalizeCssIsolation(cssIsolation))) {
|
|
148
|
-
plugins.push(createNamespaceCssPlugin());
|
|
149
|
-
}
|
|
150
|
-
plugins.push(autoprefixer());
|
|
151
|
-
return {
|
|
152
|
-
postcss: {
|
|
153
|
-
plugins,
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async function createReactPlugin() {
|
|
159
|
-
const reactPluginModule = await import("@vitejs/plugin-react");
|
|
160
|
-
return reactPluginModule.default();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function parseArgs(argv) {
|
|
164
|
-
const result = {
|
|
165
|
-
form: "",
|
|
166
|
-
force: false,
|
|
167
|
-
only: "",
|
|
168
|
-
dryRun: false,
|
|
169
|
-
cleanCache: false,
|
|
170
|
-
runtimeCache: process.env.APP_RUNTIME_CACHE !== "false",
|
|
171
|
-
help: false,
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
175
|
-
const arg = argv[i];
|
|
176
|
-
|
|
177
|
-
if (arg === "--help" || arg === "-h") {
|
|
178
|
-
result.help = true;
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
if (arg === "--form" && argv[i + 1]) {
|
|
182
|
-
result.form = argv[i + 1];
|
|
183
|
-
i += 1;
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
if (arg === "--only" && argv[i + 1]) {
|
|
187
|
-
result.only = argv[i + 1];
|
|
188
|
-
i += 1;
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
if (arg.startsWith("--only=")) {
|
|
192
|
-
result.only = arg.slice("--only=".length);
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (arg === "--force") {
|
|
196
|
-
result.force = true;
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
if (arg === "--dry-run") {
|
|
200
|
-
result.dryRun = true;
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
if (arg === "--clean-cache") {
|
|
204
|
-
result.cleanCache = true;
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
if (arg === `--${["bundle", "mode"].join("-")}`) {
|
|
208
|
-
throw new Error("runtime mode flag has been removed");
|
|
209
|
-
}
|
|
210
|
-
if (arg === "--no-runtime-cache") {
|
|
211
|
-
result.runtimeCache = false;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return result;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function printHelp() {
|
|
219
|
-
console.log(`
|
|
220
|
-
build-forms - 构建表单页面
|
|
221
|
-
|
|
222
|
-
用法:
|
|
223
|
-
tsx scripts/build-forms.mjs [options]
|
|
224
|
-
|
|
225
|
-
选项:
|
|
226
|
-
--form <name> 只构建指定表单(src/forms/ 下的目录名)
|
|
227
|
-
--only <list> 只构建指定模块,如 forms/customer,pages/dashboard
|
|
228
|
-
--force 忽略增量缓存,强制重建表单产物
|
|
229
|
-
--dry-run 只打印增量计划,不构建
|
|
230
|
-
--clean-cache 删除 .openxiangda/build-cache.json
|
|
231
|
-
--no-runtime-cache 强制重建共享 runtime
|
|
232
|
-
--help, -h 显示帮助信息
|
|
233
|
-
`);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function discoverForms(filterName) {
|
|
237
|
-
if (!fs.existsSync(formsDir)) {
|
|
238
|
-
console.error(`错误: 找不到表单目录 ${formsDir}`);
|
|
239
|
-
process.exit(1);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const entries = fs.readdirSync(formsDir, { withFileTypes: true });
|
|
243
|
-
const formDirs = entries
|
|
244
|
-
.filter((entry) => entry.isDirectory())
|
|
245
|
-
.filter((entry) => (filterName ? entry.name === filterName : true))
|
|
246
|
-
.filter((entry) => {
|
|
247
|
-
const schemaPath = path.join(formsDir, entry.name, "schema.ts");
|
|
248
|
-
return fs.existsSync(schemaPath);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
return formDirs.map((entry) => ({
|
|
252
|
-
name: entry.name,
|
|
253
|
-
key: `forms/${entry.name}`,
|
|
254
|
-
dirPath: path.join(formsDir, entry.name),
|
|
255
|
-
entryPath: path.join(formsDir, entry.name, "page.tsx"),
|
|
256
|
-
schemaPath: path.join(formsDir, entry.name, "schema.ts"),
|
|
257
|
-
outDir: path.join(distDir, entry.name),
|
|
258
|
-
}));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function createRuntimeEntryContent() {
|
|
262
|
-
const workspaceStyleImport = createWorkspaceStyleImport(rootDir, tmpDir);
|
|
263
|
-
return `import React from 'react';
|
|
264
|
-
import { createRoot } from 'react-dom/client';
|
|
265
|
-
import { StyleProvider } from '@ant-design/cssinjs';
|
|
266
|
-
import { App as AntdApp, ConfigProvider, message } from 'antd';
|
|
267
|
-
import zhCN from 'antd/locale/zh_CN';
|
|
268
|
-
import dayjs from 'dayjs';
|
|
269
|
-
import 'dayjs/locale/zh-cn';
|
|
270
|
-
import * as SyFormComponentsModule from 'openxiangda';
|
|
271
|
-
import { antdTheme, legacyAntdTheme } from 'openxiangda/antd-theme';
|
|
272
|
-
import 'antd-mobile/es/global';
|
|
273
|
-
import '${workspaceStyleImport}';
|
|
274
|
-
|
|
275
|
-
const runtimeVersion = '${runtimeVersionPlaceholder}';
|
|
276
|
-
dayjs.locale('zh-cn');
|
|
277
|
-
|
|
278
|
-
const roots = new WeakMap();
|
|
279
|
-
const portalContainerCleanups = new WeakMap();
|
|
280
|
-
const { StandardFormPage, defineFormSchema } = SyFormComponentsModule;
|
|
281
|
-
const NAMESPACE_ROOT_CLASS = 'sy-app-workspace';
|
|
282
|
-
const RUNTIME_PORTAL_ATTR = 'data-sy-runtime-portal';
|
|
283
|
-
const PORTAL_CONTAINER_STACK_GLOBAL = '__OPENXIANGDA_PORTAL_CONTAINER_STACK__';
|
|
284
|
-
const PORTAL_CONTAINER_RESOLVER_GLOBAL = '${portalContainerResolverGlobal}';
|
|
285
|
-
const MESSAGE_PROXY_GLOBAL = '__OPENXIANGDA_ANTD_MESSAGE_PROXY__';
|
|
286
|
-
const MESSAGE_METHODS = ['open', 'success', 'info', 'warning', 'error', 'loading', 'destroy'];
|
|
287
|
-
const portalContainers = new WeakMap();
|
|
288
|
-
const portalCssIsolations = new WeakMap();
|
|
289
|
-
|
|
290
|
-
function normalizeRuntimeCssIsolation(value) {
|
|
291
|
-
return value === 'namespace' || value === 'shadow' ? value : 'none';
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function getRuntimeCssIsolation(context = {}) {
|
|
295
|
-
return normalizeRuntimeCssIsolation(
|
|
296
|
-
context.cssIsolation ||
|
|
297
|
-
context.runtime?.cssIsolation ||
|
|
298
|
-
context.page?.capabilities?.cssIsolation,
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function usesLegacyCssIsolation(cssIsolation) {
|
|
303
|
-
return cssIsolation === 'namespace' || cssIsolation === 'shadow';
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function getAntdRuntimeOptions(cssIsolation) {
|
|
307
|
-
const legacy = usesLegacyCssIsolation(cssIsolation);
|
|
308
|
-
return {
|
|
309
|
-
prefixCls: legacy ? 'sy-ant' : 'ant',
|
|
310
|
-
iconPrefixCls: legacy ? 'sy-anticon' : 'anticon',
|
|
311
|
-
messagePrefixCls: legacy ? 'sy-ant-message' : 'ant-message',
|
|
312
|
-
theme: legacy ? legacyAntdTheme : antdTheme,
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function getStyleContainer(el) {
|
|
317
|
-
const rootNode = el.getRootNode?.();
|
|
318
|
-
return typeof ShadowRoot !== 'undefined' && rootNode instanceof ShadowRoot
|
|
319
|
-
? rootNode
|
|
320
|
-
: document.head;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function isShadowRoot(rootNode) {
|
|
324
|
-
return typeof ShadowRoot !== 'undefined' && rootNode instanceof ShadowRoot;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function getRuntimeRoot(el, triggerNode) {
|
|
328
|
-
if (isShadowRoot(el.getRootNode?.())) return el;
|
|
329
|
-
const triggerRoot = triggerNode?.closest?.('.' + NAMESPACE_ROOT_CLASS);
|
|
330
|
-
return (
|
|
331
|
-
triggerRoot ||
|
|
332
|
-
el.closest?.('.' + NAMESPACE_ROOT_CLASS) ||
|
|
333
|
-
el.querySelector?.('.' + NAMESPACE_ROOT_CLASS) ||
|
|
334
|
-
el
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function getOverlayRoot(el, portalContainer, triggerNode) {
|
|
339
|
-
return portalContainer?.isConnected ? portalContainer : getRuntimeRoot(el, triggerNode);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function getPopupContainer(el, portalContainer) {
|
|
343
|
-
return (triggerNode) => getOverlayRoot(el, portalContainer, triggerNode);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
function getTargetContainer(el) {
|
|
347
|
-
return () => getRuntimeRoot(el);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
function createAntdConfig(el, portalContainer, cssIsolation) {
|
|
351
|
-
const antdOptions = getAntdRuntimeOptions(cssIsolation);
|
|
352
|
-
return {
|
|
353
|
-
locale: zhCN,
|
|
354
|
-
prefixCls: antdOptions.prefixCls,
|
|
355
|
-
iconPrefixCls: antdOptions.iconPrefixCls,
|
|
356
|
-
theme: antdOptions.theme,
|
|
357
|
-
...(usesLegacyCssIsolation(cssIsolation)
|
|
358
|
-
? {
|
|
359
|
-
getPopupContainer: getPopupContainer(el, portalContainer),
|
|
360
|
-
getTargetContainer: getTargetContainer(el),
|
|
361
|
-
}
|
|
362
|
-
: {}),
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
function createPortalContainer(el) {
|
|
367
|
-
const rootNode = el.getRootNode?.();
|
|
368
|
-
const parent = isShadowRoot(rootNode) ? rootNode : el.ownerDocument.body;
|
|
369
|
-
const portalContainer = el.ownerDocument.createElement('div');
|
|
370
|
-
portalContainer.setAttribute(RUNTIME_PORTAL_ATTR, '');
|
|
371
|
-
portalContainer.classList.add(NAMESPACE_ROOT_CLASS);
|
|
372
|
-
parent.appendChild(portalContainer);
|
|
373
|
-
return portalContainer;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function getAntdMessageProxyState() {
|
|
377
|
-
if (!globalThis[MESSAGE_PROXY_GLOBAL]) {
|
|
378
|
-
globalThis[MESSAGE_PROXY_GLOBAL] = {
|
|
379
|
-
apiStack: [],
|
|
380
|
-
installed: false,
|
|
381
|
-
originalMethods: {},
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
return globalThis[MESSAGE_PROXY_GLOBAL];
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function installAntdMessageProxy() {
|
|
388
|
-
const state = getAntdMessageProxyState();
|
|
389
|
-
if (state.installed) return state;
|
|
390
|
-
MESSAGE_METHODS.forEach((method) => {
|
|
391
|
-
const originalMethod = message[method];
|
|
392
|
-
if (typeof originalMethod !== 'function') return;
|
|
393
|
-
state.originalMethods[method] = originalMethod.bind(message);
|
|
394
|
-
message[method] = (...args) => {
|
|
395
|
-
const api = state.apiStack[state.apiStack.length - 1];
|
|
396
|
-
const apiMethod = api?.[method];
|
|
397
|
-
if (typeof apiMethod === 'function') {
|
|
398
|
-
return apiMethod(...args);
|
|
399
|
-
}
|
|
400
|
-
return state.originalMethods[method]?.(...args);
|
|
401
|
-
};
|
|
402
|
-
});
|
|
403
|
-
state.installed = true;
|
|
404
|
-
return state;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function registerAntdMessageApi(api) {
|
|
408
|
-
const state = installAntdMessageProxy();
|
|
409
|
-
state.apiStack.push(api);
|
|
410
|
-
return () => {
|
|
411
|
-
const position = state.apiStack.lastIndexOf(api);
|
|
412
|
-
if (position >= 0) state.apiStack.splice(position, 1);
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function installRuntimePortalContainer(el, cssIsolation) {
|
|
417
|
-
const portalContainer = usesLegacyCssIsolation(cssIsolation)
|
|
418
|
-
? createPortalContainer(el)
|
|
419
|
-
: null;
|
|
420
|
-
const stack = Array.isArray(globalThis[PORTAL_CONTAINER_STACK_GLOBAL])
|
|
421
|
-
? globalThis[PORTAL_CONTAINER_STACK_GLOBAL]
|
|
422
|
-
: [];
|
|
423
|
-
const stackTarget = portalContainer || el.ownerDocument.body;
|
|
424
|
-
stack.push(stackTarget);
|
|
425
|
-
globalThis[PORTAL_CONTAINER_STACK_GLOBAL] = stack;
|
|
426
|
-
globalThis[PORTAL_CONTAINER_RESOLVER_GLOBAL] = () => {
|
|
427
|
-
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
428
|
-
const candidate = stack[index];
|
|
429
|
-
if (candidate?.isConnected) {
|
|
430
|
-
return candidate;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
return (
|
|
434
|
-
document.querySelector('[' + RUNTIME_PORTAL_ATTR + ']') ||
|
|
435
|
-
document.querySelector('.' + NAMESPACE_ROOT_CLASS) ||
|
|
436
|
-
document.body
|
|
437
|
-
);
|
|
438
|
-
};
|
|
439
|
-
return {
|
|
440
|
-
container: portalContainer,
|
|
441
|
-
release: () => {
|
|
442
|
-
const position = stack.lastIndexOf(stackTarget);
|
|
443
|
-
if (position >= 0) stack.splice(position, 1);
|
|
444
|
-
portalContainer?.remove();
|
|
445
|
-
},
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function installAntdStaticHolder(el, portalContainer, cssIsolation) {
|
|
450
|
-
installAntdMessageProxy();
|
|
451
|
-
const antdOptions = getAntdRuntimeOptions(cssIsolation);
|
|
452
|
-
const getMessageContainer = () =>
|
|
453
|
-
portalContainer?.isConnected
|
|
454
|
-
? portalContainer
|
|
455
|
-
: usesLegacyCssIsolation(cssIsolation)
|
|
456
|
-
? getRuntimeRoot(el)
|
|
457
|
-
: document.body;
|
|
458
|
-
|
|
459
|
-
ConfigProvider.config({
|
|
460
|
-
prefixCls: antdOptions.prefixCls,
|
|
461
|
-
iconPrefixCls: antdOptions.iconPrefixCls,
|
|
462
|
-
theme: antdOptions.theme,
|
|
463
|
-
holderRender: (children) => {
|
|
464
|
-
if (!el.isConnected) {
|
|
465
|
-
return (
|
|
466
|
-
<ConfigProvider locale={zhCN} prefixCls={antdOptions.prefixCls} iconPrefixCls={antdOptions.iconPrefixCls} theme={antdOptions.theme}>
|
|
467
|
-
{children}
|
|
468
|
-
</ConfigProvider>
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
return (
|
|
472
|
-
<StyleProvider hashPriority="high" container={getStyleContainer(el)}>
|
|
473
|
-
<ConfigProvider {...createAntdConfig(el, portalContainer, cssIsolation)}>{children}</ConfigProvider>
|
|
474
|
-
</StyleProvider>
|
|
475
|
-
);
|
|
476
|
-
},
|
|
477
|
-
});
|
|
478
|
-
message.config({
|
|
479
|
-
prefixCls: antdOptions.messagePrefixCls,
|
|
480
|
-
getContainer: getMessageContainer,
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
function RuntimeMessageBridge({ children }) {
|
|
485
|
-
const appContext = AntdApp.useApp();
|
|
486
|
-
React.useLayoutEffect(() => {
|
|
487
|
-
return registerAntdMessageApi(appContext.message);
|
|
488
|
-
}, [appContext.message]);
|
|
489
|
-
return <>{children}</>;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function renderStandardForm(el, schemaInput, context = {}) {
|
|
493
|
-
let root = roots.get(el);
|
|
494
|
-
const cssIsolation = getRuntimeCssIsolation(context);
|
|
495
|
-
if (usesLegacyCssIsolation(cssIsolation)) {
|
|
496
|
-
el.classList.add(NAMESPACE_ROOT_CLASS);
|
|
497
|
-
} else {
|
|
498
|
-
el.classList.remove(NAMESPACE_ROOT_CLASS);
|
|
499
|
-
}
|
|
500
|
-
let portalContainer = portalContainers.get(el);
|
|
501
|
-
const previousCssIsolation = portalCssIsolations.get(el);
|
|
502
|
-
if (
|
|
503
|
-
previousCssIsolation !== cssIsolation ||
|
|
504
|
-
(usesLegacyCssIsolation(cssIsolation) && !portalContainer?.isConnected) ||
|
|
505
|
-
(!usesLegacyCssIsolation(cssIsolation) && portalContainer)
|
|
506
|
-
) {
|
|
507
|
-
const cleanup = portalContainerCleanups.get(el);
|
|
508
|
-
if (cleanup) cleanup();
|
|
509
|
-
const portalHandle = installRuntimePortalContainer(el, cssIsolation);
|
|
510
|
-
portalContainer = portalHandle.container;
|
|
511
|
-
if (portalContainer) {
|
|
512
|
-
portalContainers.set(el, portalContainer);
|
|
513
|
-
} else {
|
|
514
|
-
portalContainers.delete(el);
|
|
515
|
-
}
|
|
516
|
-
portalCssIsolations.set(el, cssIsolation);
|
|
517
|
-
portalContainerCleanups.set(el, portalHandle.release);
|
|
518
|
-
}
|
|
519
|
-
installAntdStaticHolder(el, portalContainer, cssIsolation);
|
|
520
|
-
if (!root) {
|
|
521
|
-
root = createRoot(el);
|
|
522
|
-
roots.set(el, root);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const schema = defineFormSchema(schemaInput);
|
|
526
|
-
const antdConfig = createAntdConfig(el, portalContainer, cssIsolation);
|
|
527
|
-
const content = (
|
|
528
|
-
<StandardFormPage
|
|
529
|
-
schema={schema}
|
|
530
|
-
mode={context.mode || 'submit'}
|
|
531
|
-
initialValues={context.initialValues}
|
|
532
|
-
permissions={context.permissions}
|
|
533
|
-
formUuid={context.formUuid}
|
|
534
|
-
appType={context.appType}
|
|
535
|
-
formInstanceId={context.formInstanceId}
|
|
536
|
-
onSubmit={context.onSubmit}
|
|
537
|
-
inDrawer={context.inDrawer}
|
|
538
|
-
/>
|
|
539
|
-
);
|
|
540
|
-
root.render(
|
|
541
|
-
<StyleProvider hashPriority="high" container={getStyleContainer(el)}>
|
|
542
|
-
<ConfigProvider {...antdConfig}>
|
|
543
|
-
<AntdApp>
|
|
544
|
-
<RuntimeMessageBridge>
|
|
545
|
-
{usesLegacyCssIsolation(cssIsolation) ? (
|
|
546
|
-
<div className="sy-app-workspace">{content}</div>
|
|
547
|
-
) : (
|
|
548
|
-
content
|
|
549
|
-
)}
|
|
550
|
-
</RuntimeMessageBridge>
|
|
551
|
-
</AntdApp>
|
|
552
|
-
</ConfigProvider>
|
|
553
|
-
</StyleProvider>
|
|
554
|
-
);
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
function unmountStandardForm(el) {
|
|
558
|
-
const root = roots.get(el);
|
|
559
|
-
if (root) {
|
|
560
|
-
root.unmount();
|
|
561
|
-
roots.delete(el);
|
|
562
|
-
}
|
|
563
|
-
const releasePortalContainer = portalContainerCleanups.get(el);
|
|
564
|
-
if (releasePortalContainer) {
|
|
565
|
-
releasePortalContainer();
|
|
566
|
-
portalContainerCleanups.delete(el);
|
|
567
|
-
portalContainers.delete(el);
|
|
568
|
-
portalCssIsolations.delete(el);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
export function createStandardFormModule(schemaInput) {
|
|
573
|
-
let currentEl = null;
|
|
574
|
-
return {
|
|
575
|
-
mount(el, context = {}) {
|
|
576
|
-
currentEl = el;
|
|
577
|
-
renderStandardForm(el, schemaInput, context);
|
|
578
|
-
},
|
|
579
|
-
update(el, nextContext = {}) {
|
|
580
|
-
const target = currentEl || el;
|
|
581
|
-
if (target) {
|
|
582
|
-
renderStandardForm(target, schemaInput, nextContext);
|
|
583
|
-
}
|
|
584
|
-
},
|
|
585
|
-
unmount(el) {
|
|
586
|
-
const target = el || currentEl;
|
|
587
|
-
if (target) {
|
|
588
|
-
unmountStandardForm(target);
|
|
589
|
-
}
|
|
590
|
-
currentEl = null;
|
|
591
|
-
},
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
export const formRuntime = {
|
|
596
|
-
protocol: 'sy-form-runtime',
|
|
597
|
-
majorVersion: 2,
|
|
598
|
-
version: runtimeVersion,
|
|
599
|
-
modules: {
|
|
600
|
-
'openxiangda': SyFormComponentsModule,
|
|
601
|
-
},
|
|
602
|
-
createStandardFormModule,
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
globalThis.SY_FORM_RUNTIME_V2 = formRuntime;
|
|
606
|
-
|
|
607
|
-
export default formRuntime;
|
|
608
|
-
`;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
function createAntdMobilePortalPatchPlugin() {
|
|
612
|
-
const resolverExpression = `globalThis.${portalContainerResolverGlobal}?.() || document.body`;
|
|
613
|
-
return {
|
|
614
|
-
name: "openxiangda-antd-mobile-portal-container",
|
|
615
|
-
transform(code, id) {
|
|
616
|
-
if (!id.includes("/antd-mobile/") && !id.includes("\\\\antd-mobile\\\\")) {
|
|
617
|
-
return null;
|
|
618
|
-
}
|
|
619
|
-
const nextCode = code.replace(
|
|
620
|
-
/getContainer:\s*\(\)\s*=>\s*document\.body/g,
|
|
621
|
-
`getContainer: () => ${resolverExpression}`,
|
|
622
|
-
);
|
|
623
|
-
if (nextCode === code) return null;
|
|
624
|
-
return { code: nextCode, map: null };
|
|
625
|
-
},
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
function createFormRuntimeProxyPlugin() {
|
|
630
|
-
return {
|
|
631
|
-
name: "sy-form-runtime-proxy",
|
|
632
|
-
enforce: "pre",
|
|
633
|
-
resolveId(source) {
|
|
634
|
-
if (source === "openxiangda")
|
|
635
|
-
return "\0sy-form-runtime-proxy:openxiangda";
|
|
636
|
-
return null;
|
|
637
|
-
},
|
|
638
|
-
load(id) {
|
|
639
|
-
if (id !== "\0sy-form-runtime-proxy:openxiangda") return null;
|
|
640
|
-
return `const runtime = globalThis.SY_FORM_RUNTIME_V2;
|
|
641
|
-
if (!runtime || runtime.protocol !== 'sy-form-runtime' || runtime.majorVersion !== 2) {
|
|
642
|
-
throw new Error('表单共享运行时未加载或版本不兼容');
|
|
643
|
-
}
|
|
644
|
-
const moduleValue = runtime.modules['openxiangda'];
|
|
645
|
-
export const defineFormSchema = moduleValue.defineFormSchema;
|
|
646
|
-
export default moduleValue;
|
|
647
|
-
`;
|
|
648
|
-
},
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
function generateRuntimeEntryFile(entryContent) {
|
|
653
|
-
const entryPath = path.join(tmpDir, "form-runtime-entry.jsx");
|
|
654
|
-
fs.writeFileSync(entryPath, entryContent, "utf-8");
|
|
655
|
-
return entryPath;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
function generateSharedEntryFile(formName) {
|
|
659
|
-
const entryContent = `import schema from '../src/forms/${formName}/schema';
|
|
660
|
-
|
|
661
|
-
const runtime = globalThis.SY_FORM_RUNTIME_V2;
|
|
662
|
-
|
|
663
|
-
if (!runtime || runtime.protocol !== 'sy-form-runtime' || runtime.majorVersion !== 2) {
|
|
664
|
-
throw new Error('表单共享运行时未加载或版本不兼容');
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
const page = runtime.createStandardFormModule(schema);
|
|
668
|
-
|
|
669
|
-
export const mount = page.mount;
|
|
670
|
-
export const update = page.update;
|
|
671
|
-
export const unmount = page.unmount;
|
|
672
|
-
|
|
673
|
-
export default page;
|
|
674
|
-
`;
|
|
675
|
-
|
|
676
|
-
const entryPath = path.join(tmpDir, `${formName}-shared-entry.js`);
|
|
677
|
-
fs.writeFileSync(entryPath, entryContent, "utf-8");
|
|
678
|
-
return entryPath;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
function readRuntimeManifest() {
|
|
682
|
-
const manifestPath = path.join(runtimeDistDir, "manifest.json");
|
|
683
|
-
if (!fs.existsSync(manifestPath)) return null;
|
|
684
|
-
try {
|
|
685
|
-
return JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
686
|
-
} catch {
|
|
687
|
-
return null;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function readRuntimeBuildCache() {
|
|
692
|
-
const cachePath = path.join(runtimeDistDir, runtimeCacheFileName);
|
|
693
|
-
if (!fs.existsSync(cachePath)) return null;
|
|
694
|
-
try {
|
|
695
|
-
return JSON.parse(fs.readFileSync(cachePath, "utf-8"));
|
|
696
|
-
} catch {
|
|
697
|
-
return null;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
function isRuntimeCacheValid(inputHash) {
|
|
702
|
-
const manifest = readRuntimeManifest();
|
|
703
|
-
const cache = readRuntimeBuildCache();
|
|
704
|
-
if (
|
|
705
|
-
!manifest ||
|
|
706
|
-
manifest.protocol !== "sy-form-runtime" ||
|
|
707
|
-
manifest.majorVersion !== 2 ||
|
|
708
|
-
!manifest.version ||
|
|
709
|
-
!manifest.files?.entry ||
|
|
710
|
-
!cache ||
|
|
711
|
-
cache.inputHash !== inputHash ||
|
|
712
|
-
cache.runtimeVersion !== manifest.version
|
|
713
|
-
) {
|
|
714
|
-
return false;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
const runtimeJsPath = path.join(runtimeDistDir, manifest.files.entry);
|
|
718
|
-
if (!fs.existsSync(runtimeJsPath)) return false;
|
|
719
|
-
const runtimeCode = fs.readFileSync(runtimeJsPath, "utf-8");
|
|
720
|
-
if (/\bjsxDEV\b|react\/jsx-dev-runtime/.test(runtimeCode)) return false;
|
|
721
|
-
if (
|
|
722
|
-
manifest.files.css &&
|
|
723
|
-
!fs.existsSync(path.join(runtimeDistDir, manifest.files.css))
|
|
724
|
-
) {
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
|
-
try {
|
|
728
|
-
validateRuntimeCssFile(
|
|
729
|
-
path.join(runtimeDistDir, manifest.files.css || "style.css"),
|
|
730
|
-
{
|
|
731
|
-
label: "表单共享 runtime",
|
|
732
|
-
},
|
|
733
|
-
);
|
|
734
|
-
} catch {
|
|
735
|
-
return false;
|
|
736
|
-
}
|
|
737
|
-
return true;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
function logRuntimeAssetSummary(prefix = "共享 runtime") {
|
|
741
|
-
const manifest = readRuntimeManifest();
|
|
742
|
-
if (!manifest) return;
|
|
743
|
-
const runtimeJsPath = path.join(
|
|
744
|
-
runtimeDistDir,
|
|
745
|
-
manifest.files?.entry || "runtime.js",
|
|
746
|
-
);
|
|
747
|
-
const runtimeCssPath = path.join(
|
|
748
|
-
runtimeDistDir,
|
|
749
|
-
manifest.files?.css || "style.css",
|
|
750
|
-
);
|
|
751
|
-
console.log(`[build] ${prefix} version: ${manifest.version}`);
|
|
752
|
-
console.log(
|
|
753
|
-
`[build] runtime.js: ${fileSizeLabel(runtimeJsPath)} / gzip ${fileGzipSizeLabel(runtimeJsPath)}`,
|
|
754
|
-
);
|
|
755
|
-
console.log(
|
|
756
|
-
`[build] style.css: ${fileSizeLabel(runtimeCssPath)} / gzip ${fileGzipSizeLabel(runtimeCssPath)}`,
|
|
757
|
-
);
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
async function buildSharedRuntime(options = {}) {
|
|
761
|
-
const startedAt = Date.now();
|
|
762
|
-
const entryContent = createRuntimeEntryContent();
|
|
763
|
-
const config = await getWorkspaceConfig();
|
|
764
|
-
const cssIsolation = normalizeCssIsolation(config.defaults?.cssIsolation);
|
|
765
|
-
const inputHash = createRuntimeInputHash(entryContent, cssIsolation);
|
|
766
|
-
if (options.runtimeCache !== false && isRuntimeCacheValid(inputHash)) {
|
|
767
|
-
console.log("[build] 表单共享 runtime 缓存命中,跳过构建");
|
|
768
|
-
logRuntimeAssetSummary("缓存 runtime");
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
const entryPath = generateRuntimeEntryFile(entryContent);
|
|
773
|
-
|
|
774
|
-
try {
|
|
775
|
-
console.log("[build] 构建表单共享 runtime");
|
|
776
|
-
const cssOptions = await createCssOptions(cssIsolation);
|
|
777
|
-
const reactPlugin = await createReactPlugin();
|
|
778
|
-
await build({
|
|
779
|
-
configFile: false,
|
|
780
|
-
mode: "production",
|
|
781
|
-
root: rootDir,
|
|
782
|
-
publicDir: false,
|
|
783
|
-
css: cssOptions,
|
|
784
|
-
define: {
|
|
785
|
-
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
786
|
-
"process.env": JSON.stringify({ NODE_ENV: "production" }),
|
|
787
|
-
},
|
|
788
|
-
resolve: {
|
|
789
|
-
alias: [
|
|
790
|
-
{
|
|
791
|
-
find: "@",
|
|
792
|
-
replacement: path.join(rootDir, "src"),
|
|
793
|
-
},
|
|
794
|
-
],
|
|
795
|
-
},
|
|
796
|
-
build: {
|
|
797
|
-
target: "es2018",
|
|
798
|
-
assetsInlineLimit: 0,
|
|
799
|
-
outDir: runtimeDistDir,
|
|
800
|
-
emptyOutDir: true,
|
|
801
|
-
cssCodeSplit: false,
|
|
802
|
-
minify: true,
|
|
803
|
-
lib: {
|
|
804
|
-
entry: entryPath,
|
|
805
|
-
formats: ["es"],
|
|
806
|
-
fileName: () => "runtime.js",
|
|
807
|
-
},
|
|
808
|
-
rollupOptions: {
|
|
809
|
-
output: {
|
|
810
|
-
inlineDynamicImports: true,
|
|
811
|
-
entryFileNames: "runtime.js",
|
|
812
|
-
chunkFileNames: "runtime.js",
|
|
813
|
-
assetFileNames: (assetInfo) => {
|
|
814
|
-
if (String(assetInfo.name || "").endsWith(".css")) {
|
|
815
|
-
return "style.css";
|
|
816
|
-
}
|
|
817
|
-
return "[name][extname]";
|
|
818
|
-
},
|
|
819
|
-
},
|
|
820
|
-
},
|
|
821
|
-
},
|
|
822
|
-
plugins: [createAntdMobilePortalPatchPlugin(), reactPlugin],
|
|
823
|
-
logLevel: "warn",
|
|
824
|
-
});
|
|
825
|
-
|
|
826
|
-
const runtimeJsPath = path.join(runtimeDistDir, "runtime.js");
|
|
827
|
-
const runtimeCssPath = path.join(runtimeDistDir, "style.css");
|
|
828
|
-
const extractedAssets = extractLargeDataUrlAssets({
|
|
829
|
-
outDir: runtimeDistDir,
|
|
830
|
-
files: [runtimeJsPath, runtimeCssPath],
|
|
831
|
-
});
|
|
832
|
-
const extractedSummary = formatExtractedAssetSummary(extractedAssets);
|
|
833
|
-
if (extractedSummary) console.log(`[build] ${extractedSummary}`);
|
|
834
|
-
validateRuntimeCssFile(runtimeCssPath, { label: "表单共享 runtime" });
|
|
835
|
-
const runtimeOutputCode = fs.readFileSync(runtimeJsPath, "utf-8");
|
|
836
|
-
if (/\bjsxDEV\b|react\/jsx-dev-runtime/.test(runtimeOutputCode)) {
|
|
837
|
-
throw new Error(
|
|
838
|
-
"表单共享 runtime 包含开发态 JSX runtime(jsxDEV/react/jsx-dev-runtime),请使用生产模式重新构建",
|
|
839
|
-
);
|
|
840
|
-
}
|
|
841
|
-
const runtimeJs = fs.readFileSync(runtimeJsPath);
|
|
842
|
-
const runtimeCss = fs.existsSync(runtimeCssPath)
|
|
843
|
-
? fs.readFileSync(runtimeCssPath)
|
|
844
|
-
: Buffer.alloc(0);
|
|
845
|
-
const hash = crypto
|
|
846
|
-
.createHash("sha256")
|
|
847
|
-
.update(runtimeJs)
|
|
848
|
-
.update(runtimeCss)
|
|
849
|
-
.digest("hex")
|
|
850
|
-
.slice(0, 12);
|
|
851
|
-
const runtimeVersion = `v2-${hash}`;
|
|
852
|
-
fs.writeFileSync(
|
|
853
|
-
runtimeJsPath,
|
|
854
|
-
runtimeJs
|
|
855
|
-
.toString("utf-8")
|
|
856
|
-
.split(runtimeVersionPlaceholder)
|
|
857
|
-
.join(runtimeVersion),
|
|
858
|
-
"utf-8",
|
|
859
|
-
);
|
|
860
|
-
const manifest = {
|
|
861
|
-
protocol: "sy-form-runtime",
|
|
862
|
-
majorVersion: 2,
|
|
863
|
-
version: runtimeVersion,
|
|
864
|
-
inputHash,
|
|
865
|
-
files: {
|
|
866
|
-
entry: "runtime.js",
|
|
867
|
-
css: fs.existsSync(runtimeCssPath) ? "style.css" : null,
|
|
868
|
-
},
|
|
869
|
-
sizes: {
|
|
870
|
-
entry: fs.statSync(runtimeJsPath).size,
|
|
871
|
-
entryGzip: gzipSync(fs.readFileSync(runtimeJsPath)).length,
|
|
872
|
-
css: fs.existsSync(runtimeCssPath)
|
|
873
|
-
? fs.statSync(runtimeCssPath).size
|
|
874
|
-
: 0,
|
|
875
|
-
cssGzip: fs.existsSync(runtimeCssPath)
|
|
876
|
-
? gzipSync(fs.readFileSync(runtimeCssPath)).length
|
|
877
|
-
: 0,
|
|
878
|
-
},
|
|
879
|
-
builtAt: new Date().toISOString(),
|
|
880
|
-
};
|
|
881
|
-
fs.writeFileSync(
|
|
882
|
-
path.join(runtimeDistDir, "manifest.json"),
|
|
883
|
-
JSON.stringify(manifest, null, 2),
|
|
884
|
-
"utf-8",
|
|
885
|
-
);
|
|
886
|
-
fs.writeFileSync(
|
|
887
|
-
path.join(runtimeDistDir, runtimeCacheFileName),
|
|
888
|
-
JSON.stringify(
|
|
889
|
-
{
|
|
890
|
-
inputHash,
|
|
891
|
-
runtimeVersion,
|
|
892
|
-
updatedAt: new Date().toISOString(),
|
|
893
|
-
},
|
|
894
|
-
null,
|
|
895
|
-
2,
|
|
896
|
-
),
|
|
897
|
-
"utf-8",
|
|
898
|
-
);
|
|
899
|
-
|
|
900
|
-
console.log(
|
|
901
|
-
`[build] 表单共享 runtime 构建完成,用时 ${formatDuration(startedAt)}`,
|
|
902
|
-
);
|
|
903
|
-
logRuntimeAssetSummary();
|
|
904
|
-
} finally {
|
|
905
|
-
if (fs.existsSync(entryPath)) {
|
|
906
|
-
fs.unlinkSync(entryPath);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
async function buildForm(form) {
|
|
912
|
-
const startedAt = Date.now();
|
|
913
|
-
const hasSchema = fs.existsSync(form.schemaPath);
|
|
914
|
-
if (!hasSchema) {
|
|
915
|
-
throw new Error(
|
|
916
|
-
`表单 ${form.name} 缺少 schema.ts,无法使用共享 runtime 发布`,
|
|
917
|
-
);
|
|
918
|
-
}
|
|
919
|
-
const entryPath = generateSharedEntryFile(form.name);
|
|
920
|
-
|
|
921
|
-
try {
|
|
922
|
-
console.log(`[build] 构建表单: ${form.name} (shared runtime)`);
|
|
923
|
-
const config = await getWorkspaceConfig();
|
|
924
|
-
const cssIsolation = normalizeCssIsolation(config.defaults?.cssIsolation);
|
|
925
|
-
const cssOptions = await createCssOptions(cssIsolation);
|
|
926
|
-
const reactPlugin = await createReactPlugin();
|
|
927
|
-
await build({
|
|
928
|
-
configFile: false,
|
|
929
|
-
mode: "production",
|
|
930
|
-
root: rootDir,
|
|
931
|
-
publicDir: false,
|
|
932
|
-
css: cssOptions,
|
|
933
|
-
define: {
|
|
934
|
-
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
935
|
-
"process.env": JSON.stringify({ NODE_ENV: "production" }),
|
|
936
|
-
},
|
|
937
|
-
resolve: {
|
|
938
|
-
alias: [
|
|
939
|
-
{
|
|
940
|
-
find: "@",
|
|
941
|
-
replacement: path.join(rootDir, "src"),
|
|
942
|
-
},
|
|
943
|
-
],
|
|
944
|
-
},
|
|
945
|
-
build: {
|
|
946
|
-
target: "es2018",
|
|
947
|
-
assetsInlineLimit: 0,
|
|
948
|
-
outDir: form.outDir,
|
|
949
|
-
emptyOutDir: true,
|
|
950
|
-
lib: {
|
|
951
|
-
entry: entryPath,
|
|
952
|
-
name: form.name,
|
|
953
|
-
formats: ["es"],
|
|
954
|
-
fileName: () => "index.js",
|
|
955
|
-
},
|
|
956
|
-
cssCodeSplit: false,
|
|
957
|
-
minify: true,
|
|
958
|
-
rollupOptions: {
|
|
959
|
-
output: {
|
|
960
|
-
inlineDynamicImports: true,
|
|
961
|
-
entryFileNames: "index.js",
|
|
962
|
-
chunkFileNames: "index.js",
|
|
963
|
-
assetFileNames: (assetInfo) => {
|
|
964
|
-
if (String(assetInfo.name || "").endsWith(".css")) {
|
|
965
|
-
return "style.css";
|
|
966
|
-
}
|
|
967
|
-
return "assets/[name]-[hash][extname]";
|
|
968
|
-
},
|
|
969
|
-
},
|
|
970
|
-
},
|
|
971
|
-
},
|
|
972
|
-
plugins: [
|
|
973
|
-
createAntdMobilePortalPatchPlugin(),
|
|
974
|
-
createFormRuntimeProxyPlugin(),
|
|
975
|
-
reactPlugin,
|
|
976
|
-
].filter(Boolean),
|
|
977
|
-
logLevel: "warn",
|
|
978
|
-
});
|
|
979
|
-
|
|
980
|
-
const entryOutput = path.join(form.outDir, "index.js");
|
|
981
|
-
const cssOutput = path.join(form.outDir, "style.css");
|
|
982
|
-
if (!fs.existsSync(cssOutput)) {
|
|
983
|
-
fs.writeFileSync(cssOutput, "", "utf-8");
|
|
984
|
-
}
|
|
985
|
-
const extractedAssets = extractLargeDataUrlAssets({
|
|
986
|
-
outDir: form.outDir,
|
|
987
|
-
files: [entryOutput, cssOutput],
|
|
988
|
-
});
|
|
989
|
-
const extractedSummary = formatExtractedAssetSummary(extractedAssets);
|
|
990
|
-
if (extractedSummary) console.log(`[build] ${extractedSummary}`);
|
|
991
|
-
console.log(
|
|
992
|
-
`[build] 输出: index.js ${fileSizeLabel(entryOutput)} / gzip ${fileGzipSizeLabel(entryOutput)}`,
|
|
993
|
-
);
|
|
994
|
-
console.log(
|
|
995
|
-
`[build] 输出: style.css ${fileSizeLabel(cssOutput)} / gzip ${fileGzipSizeLabel(cssOutput)}`,
|
|
996
|
-
);
|
|
997
|
-
const outputCode = fs.readFileSync(entryOutput, "utf-8");
|
|
998
|
-
const bareImportMatch = outputCode.match(
|
|
999
|
-
/\bfrom\s*["'](?:react|react-dom|react\/jsx-runtime|antd|openxiangda|antd-mobile|@tiptap\/[^"']+)["']/,
|
|
1000
|
-
);
|
|
1001
|
-
if (bareImportMatch) {
|
|
1002
|
-
throw new Error(
|
|
1003
|
-
`构建产物仍包含浏览器无法直接加载的裸模块导入: ${bareImportMatch[0]}`,
|
|
1004
|
-
);
|
|
1005
|
-
}
|
|
1006
|
-
if (/(?:react-dom\/client|antd-mobile|@tiptap\/)/.test(outputCode)) {
|
|
1007
|
-
throw new Error(
|
|
1008
|
-
"shared 表单产物仍包含运行时依赖代码,请检查入口生成逻辑",
|
|
1009
|
-
);
|
|
1010
|
-
}
|
|
1011
|
-
if (/\bprocess\.env\b/.test(outputCode)) {
|
|
1012
|
-
throw new Error("构建产物仍包含浏览器不存在的 process.env 引用");
|
|
1013
|
-
}
|
|
1014
|
-
if (/\bjsxDEV\b|react\/jsx-dev-runtime/.test(outputCode)) {
|
|
1015
|
-
throw new Error(
|
|
1016
|
-
"构建产物包含开发态 JSX runtime(jsxDEV/react/jsx-dev-runtime),请使用生产模式重新构建",
|
|
1017
|
-
);
|
|
1018
|
-
}
|
|
1019
|
-
console.log(
|
|
1020
|
-
`[build] 表单 ${form.name} 构建完成,用时 ${formatDuration(startedAt)}`,
|
|
1021
|
-
);
|
|
1022
|
-
} finally {
|
|
1023
|
-
if (fs.existsSync(entryPath)) {
|
|
1024
|
-
fs.unlinkSync(entryPath);
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
async function main() {
|
|
1030
|
-
const args = parseArgs(process.argv.slice(2));
|
|
1031
|
-
|
|
1032
|
-
if (args.help) {
|
|
1033
|
-
printHelp();
|
|
1034
|
-
process.exit(0);
|
|
1035
|
-
}
|
|
1036
|
-
if (args.cleanCache) {
|
|
1037
|
-
cleanBuildCache();
|
|
1038
|
-
console.log("[build] 已删除 .openxiangda/build-cache.json");
|
|
1039
|
-
return;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
const startedAt = Date.now();
|
|
1043
|
-
console.log("[build] 构建表单页面");
|
|
1044
|
-
console.log("[build] 构建模式: shared runtime");
|
|
1045
|
-
const onlyTargets = normalizeOnly(args.only);
|
|
1046
|
-
const only = onlyTargets.filter((item) => item.startsWith("forms/"));
|
|
1047
|
-
if (onlyTargets.length > 0 && only.length === 0) {
|
|
1048
|
-
console.log("[build] forms: No form targets selected");
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
const requested = args.form ? [`forms/${args.form}`] : only;
|
|
1052
|
-
const forms = discoverForms("");
|
|
1053
|
-
|
|
1054
|
-
if (forms.length === 0) {
|
|
1055
|
-
if (args.form) {
|
|
1056
|
-
console.error(`错误: 找不到表单 "${args.form}"`);
|
|
1057
|
-
} else {
|
|
1058
|
-
console.error("错误: 未发现任何表单页面文件");
|
|
1059
|
-
}
|
|
1060
|
-
process.exit(1);
|
|
1061
|
-
}
|
|
1062
|
-
const formKeys = new Set(forms.map((form) => form.key));
|
|
1063
|
-
const missing = requested.filter((key) => !formKeys.has(key));
|
|
1064
|
-
if (missing.length > 0) {
|
|
1065
|
-
console.error(
|
|
1066
|
-
`错误: 找不到表单 ${missing.map((key) => `"${key.slice("forms/".length)}"`).join(", ")}`,
|
|
1067
|
-
);
|
|
1068
|
-
process.exit(1);
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
const plan = planIncrementalBuild(forms, {
|
|
1072
|
-
force: args.force,
|
|
1073
|
-
only: requested.length ? requested : undefined,
|
|
1074
|
-
});
|
|
1075
|
-
printPlan(plan, "forms");
|
|
1076
|
-
if (args.dryRun) return;
|
|
1077
|
-
if (plan.changed.length === 0) return;
|
|
1078
|
-
warnShadcnTailwindTokens(rootDir);
|
|
1079
|
-
|
|
1080
|
-
if (plan.fullRebuild && requested.length === 0 && fs.existsSync(distDir)) {
|
|
1081
|
-
fs.rmSync(distDir, { recursive: true, force: true });
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
fs.mkdirSync(distDir, { recursive: true });
|
|
1085
|
-
fs.mkdirSync(tmpDir, { recursive: true });
|
|
1086
|
-
|
|
1087
|
-
await buildSharedRuntime({ runtimeCache: args.runtimeCache });
|
|
1088
|
-
console.log("");
|
|
1089
|
-
|
|
1090
|
-
let succeeded = 0;
|
|
1091
|
-
let failed = 0;
|
|
1092
|
-
|
|
1093
|
-
const built = [];
|
|
1094
|
-
for (const form of plan.changed) {
|
|
1095
|
-
try {
|
|
1096
|
-
await buildForm(form);
|
|
1097
|
-
succeeded += 1;
|
|
1098
|
-
built.push(form);
|
|
1099
|
-
} catch (error) {
|
|
1100
|
-
console.error(
|
|
1101
|
-
`[build] ${form.name} 构建失败: ${error.stack || error.message}`,
|
|
1102
|
-
);
|
|
1103
|
-
failed += 1;
|
|
1104
|
-
}
|
|
1105
|
-
console.log("");
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
try {
|
|
1109
|
-
const remaining = fs.readdirSync(tmpDir);
|
|
1110
|
-
if (remaining.length === 0) {
|
|
1111
|
-
fs.rmdirSync(tmpDir);
|
|
1112
|
-
}
|
|
1113
|
-
} catch {
|
|
1114
|
-
// ignore
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
console.log(
|
|
1118
|
-
`[build] 完成: ${succeeded} 成功, ${failed} 失败, 总耗时 ${formatDuration(
|
|
1119
|
-
startedAt,
|
|
1120
|
-
)}`,
|
|
1121
|
-
);
|
|
1122
|
-
|
|
1123
|
-
if (failed > 0) {
|
|
1124
|
-
process.exit(1);
|
|
1125
|
-
}
|
|
1126
|
-
commitIncrementalBuild(plan, built);
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
await main();
|