@blokkli/editor 1.4.0-alpha.1 → 2.0.0-alpha.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/module.d.mts +12 -194
- package/dist/module.json +4 -4
- package/dist/module.mjs +1844 -1304
- package/dist/modules/drupal/adapter/index.d.mts +6 -0
- package/dist/modules/drupal/adapter/index.mjs +762 -0
- package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliEditState.graphql +44 -0
- package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliMutatedField.graphql +11 -0
- package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliMutationItem.graphql +9 -0
- package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliMutationResult.graphql +7 -0
- package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliViolation.graphql +7 -0
- package/dist/modules/drupal/graphql/base/query.pbConfig.graphql +96 -0
- package/dist/modules/drupal/graphql/base/query.pbEditState.graphql +15 -0
- package/dist/modules/drupal/graphql/features/conversions.graphql +44 -0
- package/dist/modules/drupal/graphql/features/import-existing.graphql +34 -0
- package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/library.graphql +17 -0
- package/dist/modules/drupal/graphql/features/media-library.graphql +28 -0
- package/dist/modules/drupal/graphql/features/preview-grant.graphql +13 -0
- package/dist/modules/drupal/graphql/features/publish.graphql +15 -0
- package/dist/modules/drupal/graphql/features/publishNew.graphql +59 -0
- package/dist/modules/drupal/graphql/mutations/add.graphql +25 -0
- package/dist/modules/drupal/graphql/mutations/add_clipboard_text.graphql +25 -0
- package/dist/modules/drupal/graphql/mutations/add_entity_reference.graphql +31 -0
- package/dist/modules/drupal/graphql/mutations/add_entity_reference_multiple.graphql +25 -0
- package/dist/modules/drupal/graphql/mutations/add_file.graphql +27 -0
- package/dist/modules/drupal/graphql/mutations/add_image.graphql +27 -0
- package/dist/modules/drupal/graphql/mutations/add_video_remote.graphql +25 -0
- package/dist/modules/drupal/graphql/mutations/bulk_update_behavior_settings.graphql +15 -0
- package/dist/modules/drupal/graphql/mutations/duplicate.graphql +33 -0
- package/dist/modules/drupal/graphql/mutations/move.graphql +25 -0
- package/dist/modules/drupal/graphql/mutations/move_multiple.graphql +25 -0
- package/dist/modules/drupal/graphql/mutations/redo.graphql +14 -0
- package/dist/modules/drupal/graphql/mutations/remove.graphql +15 -0
- package/dist/modules/drupal/graphql/mutations/remove_multiple.graphql +15 -0
- package/dist/modules/drupal/graphql/mutations/replace_host_entity_media.graphql +20 -0
- package/dist/modules/drupal/graphql/mutations/replace_media.graphql +22 -0
- package/dist/modules/drupal/graphql/mutations/revertAllChanges.graphql +14 -0
- package/dist/modules/drupal/graphql/mutations/setHistoryIndex.graphql +15 -0
- package/dist/modules/drupal/graphql/mutations/setMutationStatus.graphql +16 -0
- package/dist/modules/drupal/graphql/mutations/takeOwnership.graphql +14 -0
- package/dist/modules/drupal/graphql/mutations/undo.graphql +14 -0
- package/dist/modules/drupal/graphql/mutations/update_behavior_setting.graphql +23 -0
- package/dist/modules/drupal/graphql/mutations/update_field_value.graphql +22 -0
- package/dist/modules/drupal/graphql/mutations/update_host_entity_field_value.graphql +20 -0
- package/dist/modules/drupal/index.d.mts +10 -0
- package/dist/modules/drupal/index.mjs +151 -0
- package/dist/runtime/adapter/index.d.ts +30 -4
- package/dist/runtime/blokkliPlugins/AddAction/index.vue +39 -54
- package/dist/runtime/blokkliPlugins/AddAction/index.vue.d.ts +26 -0
- package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue +38 -64
- package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue.d.ts +12 -0
- package/dist/runtime/blokkliPlugins/ContextMenu/index.vue +19 -30
- package/dist/runtime/blokkliPlugins/ContextMenu/index.vue.d.ts +37 -0
- package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue +15 -23
- package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue.d.ts +21 -0
- package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +27 -44
- package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue.d.ts +41 -0
- package/dist/runtime/blokkliPlugins/ItemAction/index.vue +39 -85
- package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +83 -0
- package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue +22 -26
- package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue.d.ts +17 -0
- package/dist/runtime/blokkliPlugins/MenuButton/index.vue +30 -38
- package/dist/runtime/blokkliPlugins/MenuButton/index.vue.d.ts +32 -0
- package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +146 -211
- package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue.d.ts +91 -0
- package/dist/runtime/blokkliPlugins/Sidebar/index.vue +95 -139
- package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +85 -0
- package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue +38 -57
- package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue.d.ts +48 -0
- package/dist/runtime/blokkliPlugins/TourItem/index.vue +20 -29
- package/dist/runtime/blokkliPlugins/TourItem/index.vue.d.ts +20 -0
- package/dist/runtime/blokkliPlugins/ViewOption/index.vue +45 -59
- package/dist/runtime/blokkliPlugins/ViewOption/index.vue.d.ts +39 -0
- package/dist/runtime/components/Blocks/Fragment/index.vue +13 -20
- package/dist/runtime/components/Blocks/Fragment/index.vue.d.ts +6 -0
- package/dist/runtime/components/Blocks/FromLibrary/index.vue +19 -29
- package/dist/runtime/components/Blocks/FromLibrary/index.vue.d.ts +6 -0
- package/dist/runtime/components/BlokkliEditable.vue +29 -49
- package/dist/runtime/components/BlokkliEditable.vue.d.ts +34 -0
- package/dist/runtime/components/BlokkliField.vue +100 -159
- package/dist/runtime/components/BlokkliField.vue.d.ts +133 -0
- package/dist/runtime/components/BlokkliItem.vue +43 -66
- package/dist/runtime/components/BlokkliItem.vue.d.ts +26 -0
- package/dist/runtime/components/BlokkliProvider.vue +50 -87
- package/dist/runtime/components/BlokkliProvider.vue.d.ts +51 -0
- package/dist/runtime/components/Edit/Actions/index.vue +116 -164
- package/dist/runtime/components/Edit/Actions/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/AddListItem/index.vue +45 -66
- package/dist/runtime/components/Edit/AddListItem/index.vue.d.ts +28 -0
- package/dist/runtime/components/Edit/AnimationCanvas/index.vue +52 -88
- package/dist/runtime/components/Edit/AnimationCanvas/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/AppMenu/index.vue +12 -15
- package/dist/runtime/components/Edit/AppMenu/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/BlockProxy/index.vue +48 -82
- package/dist/runtime/components/Edit/BlockProxy/index.vue.d.ts +10 -0
- package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue +16 -20
- package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue.d.ts +23 -0
- package/dist/runtime/components/Edit/Dialog/index.vue +67 -103
- package/dist/runtime/components/Edit/Dialog/index.vue.d.ts +44 -0
- package/dist/runtime/components/Edit/DragInteractions/index.vue +219 -333
- package/dist/runtime/components/Edit/DragInteractions/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/DraggableList.vue +82 -125
- package/dist/runtime/components/Edit/DraggableList.vue.d.ts +27 -0
- package/dist/runtime/components/Edit/EditIndicator.vue +34 -46
- package/dist/runtime/components/Edit/EditIndicator.vue.d.ts +11 -0
- package/dist/runtime/components/Edit/EditProvider.vue +144 -141
- package/dist/runtime/components/Edit/EditProvider.vue.d.ts +26 -0
- package/dist/runtime/components/Edit/Features/AddList/index.vue +90 -117
- package/dist/runtime/components/Edit/Features/AddList/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Artboard/Overview/index.vue +43 -63
- package/dist/runtime/components/Edit/Features/Artboard/Overview/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/Artboard/Scrollbar/index.vue +18 -23
- package/dist/runtime/components/Edit/Features/Artboard/Scrollbar/index.vue.d.ts +7 -0
- package/dist/runtime/components/Edit/Features/Artboard/index.vue +174 -223
- package/dist/runtime/components/Edit/Features/Artboard/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Assistant/Overlay/ResultMarkup/index.vue +7 -7
- package/dist/runtime/components/Edit/Features/Assistant/Overlay/ResultMarkup/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/Assistant/Overlay/index.vue +39 -52
- package/dist/runtime/components/Edit/Features/Assistant/Overlay/index.vue.d.ts +8 -0
- package/dist/runtime/components/Edit/Features/Assistant/index.vue +31 -40
- package/dist/runtime/components/Edit/Features/Assistant/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +225 -326
- package/dist/runtime/components/Edit/Features/BlockAddList/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Clipboard/List/Item/File.vue +36 -44
- package/dist/runtime/components/Edit/Features/Clipboard/List/Item/File.vue.d.ts +3 -0
- package/dist/runtime/components/Edit/Features/Clipboard/List/Item/Video.vue +33 -35
- package/dist/runtime/components/Edit/Features/Clipboard/List/Item/Video.vue.d.ts +3 -0
- package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue +13 -21
- package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue.d.ts +10 -0
- package/dist/runtime/components/Edit/Features/Clipboard/index.vue +226 -297
- package/dist/runtime/components/Edit/Features/Clipboard/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue +24 -34
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue.d.ts +22 -0
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +146 -195
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +21 -26
- package/dist/runtime/components/Edit/Features/CommandPalette/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue +9 -12
- package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue.d.ts +8 -0
- package/dist/runtime/components/Edit/Features/Comments/Comment/index.vue +20 -28
- package/dist/runtime/components/Edit/Features/Comments/Comment/index.vue.d.ts +23 -0
- package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue +30 -42
- package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue.d.ts +19 -0
- package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue +70 -100
- package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue.d.ts +18 -0
- package/dist/runtime/components/Edit/Features/Comments/index.vue +37 -48
- package/dist/runtime/components/Edit/Features/Comments/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Conversions/index.vue +40 -56
- package/dist/runtime/components/Edit/Features/Conversions/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +37 -50
- package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Debug/Viewport/index.vue +35 -44
- package/dist/runtime/components/Edit/Features/Debug/Viewport/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Debug/index.vue +43 -57
- package/dist/runtime/components/Edit/Features/Debug/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Delete/index.vue +31 -52
- package/dist/runtime/components/Edit/Features/Delete/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Diff/DiffView/index.vue +68 -107
- package/dist/runtime/components/Edit/Features/Diff/DiffView/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Diff/index.vue +17 -19
- package/dist/runtime/components/Edit/Features/Diff/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +193 -337
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue.d.ts +27 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/fragment.glsl +1 -1
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +391 -644
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue.d.ts +156 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +197 -323
- package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Duplicate/index.vue +49 -71
- package/dist/runtime/components/Edit/Features/Duplicate/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Edit/index.vue +41 -71
- package/dist/runtime/components/Edit/Features/Edit/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/EditForm/Frame/index.vue +35 -51
- package/dist/runtime/components/Edit/Features/EditForm/Frame/index.vue.d.ts +11 -0
- package/dist/runtime/components/Edit/Features/EditForm/index.vue +104 -140
- package/dist/runtime/components/Edit/Features/EditForm/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Contenteditable/index.vue +18 -25
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Contenteditable/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +34 -50
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue.d.ts +16 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue +40 -51
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue.d.ts +16 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +145 -207
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue.d.ts +15 -0
- package/dist/runtime/components/Edit/Features/EditableField/index.vue +90 -143
- package/dist/runtime/components/Edit/Features/EditableField/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/EditableMask/index.vue +28 -36
- package/dist/runtime/components/Edit/Features/EditableMask/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/EntityTitle/index.vue +49 -58
- package/dist/runtime/components/Edit/Features/EntityTitle/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Exit/index.vue +16 -20
- package/dist/runtime/components/Edit/Features/Exit/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/FieldAreas/Overlay/index.vue +4 -15
- package/dist/runtime/components/Edit/Features/FieldAreas/Overlay/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/FieldAreas/index.vue +19 -21
- package/dist/runtime/components/Edit/Features/FieldAreas/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue +28 -35
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue.d.ts +8 -0
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +49 -72
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/Fragments/index.vue +41 -51
- package/dist/runtime/components/Edit/Features/Fragments/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Grid/index.vue +17 -20
- package/dist/runtime/components/Edit/Features/Grid/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Help/Shortcuts/index.vue +24 -35
- package/dist/runtime/components/Edit/Features/Help/Shortcuts/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Help/index.vue +17 -21
- package/dist/runtime/components/Edit/Features/Help/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/History/List/index.vue +46 -67
- package/dist/runtime/components/Edit/Features/History/List/index.vue.d.ts +5 -0
- package/dist/runtime/components/Edit/Features/History/index.vue +54 -69
- package/dist/runtime/components/Edit/Features/History/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/ImportExisting/Dialog/index.vue +48 -66
- package/dist/runtime/components/Edit/Features/ImportExisting/Dialog/index.vue.d.ts +14 -0
- package/dist/runtime/components/Edit/Features/ImportExisting/index.vue +38 -54
- package/dist/runtime/components/Edit/Features/ImportExisting/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +88 -126
- package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue.d.ts +13 -0
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue +29 -38
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue.d.ts +9 -0
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +65 -90
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +37 -47
- package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/Library/index.vue +85 -117
- package/dist/runtime/components/Edit/Features/Library/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/Item.vue +13 -19
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/Item.vue.d.ts +19 -0
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +75 -111
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +107 -140
- package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +128 -188
- package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +42 -57
- package/dist/runtime/components/Edit/Features/MultiSelect/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Checkbox/index.vue +27 -34
- package/dist/runtime/components/Edit/Features/Options/Form/Checkbox/index.vue.d.ts +14 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Checkboxes/index.vue +55 -75
- package/dist/runtime/components/Edit/Features/Options/Form/Checkboxes/index.vue.d.ts +24 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Color/index.vue +18 -21
- package/dist/runtime/components/Edit/Features/Options/Form/Color/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/Options/Form/DateTimeLocal/index.vue +36 -0
- package/dist/runtime/components/Edit/Features/Options/Form/DateTimeLocal/index.vue.d.ts +20 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Group.vue +7 -9
- package/dist/runtime/components/Edit/Features/Options/Form/Group.vue.d.ts +29 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +87 -93
- package/dist/runtime/components/Edit/Features/Options/Form/Item.vue.d.ts +14 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Number/index.vue +31 -45
- package/dist/runtime/components/Edit/Features/Options/Form/Number/index.vue.d.ts +21 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue +54 -78
- package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue.d.ts +30 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Range/index.vue +23 -33
- package/dist/runtime/components/Edit/Features/Options/Form/Range/index.vue.d.ts +18 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Text/index.vue +17 -26
- package/dist/runtime/components/Edit/Features/Options/Form/Text/index.vue.d.ts +17 -0
- package/dist/runtime/components/Edit/Features/Options/Form/index.vue +178 -272
- package/dist/runtime/components/Edit/Features/Options/Form/index.vue.d.ts +9 -0
- package/dist/runtime/components/Edit/Features/Options/index.vue +38 -69
- package/dist/runtime/components/Edit/Features/Options/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Ownership/index.vue +26 -33
- package/dist/runtime/components/Edit/Features/Ownership/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Preview/index.vue +22 -27
- package/dist/runtime/components/Edit/Features/Preview/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/PreviewGrant/QrCode/index.vue +11 -15
- package/dist/runtime/components/Edit/Features/PreviewGrant/QrCode/index.vue.d.ts +5 -0
- package/dist/runtime/components/Edit/Features/PreviewGrant/index.vue +31 -36
- package/dist/runtime/components/Edit/Features/PreviewGrant/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/ProxyView/index.vue +18 -20
- package/dist/runtime/components/Edit/Features/ProxyView/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Publish/Dialog/Item.vue +118 -0
- package/dist/runtime/components/Edit/Features/Publish/Dialog/Item.vue.d.ts +18 -0
- package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +251 -0
- package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue.d.ts +19 -0
- package/dist/runtime/components/Edit/Features/Publish/Dialog/types.d.ts +7 -0
- package/dist/runtime/components/Edit/Features/Publish/index.vue +70 -74
- package/dist/runtime/components/Edit/Features/Publish/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue +48 -54
- package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue.d.ts +27 -0
- package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +77 -103
- package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Revert/index.vue +27 -32
- package/dist/runtime/components/Edit/Features/Revert/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +66 -87
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue.d.ts +17 -0
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue +89 -139
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue.d.ts +18 -0
- package/dist/runtime/components/Edit/Features/Search/Overlay/index.vue +79 -108
- package/dist/runtime/components/Edit/Features/Search/Overlay/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/Search/index.vue +30 -37
- package/dist/runtime/components/Edit/Features/Search/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue +67 -103
- package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue.d.ts +9 -0
- package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +28 -36
- package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue.d.ts +5 -0
- package/dist/runtime/components/Edit/Features/Selection/index.vue +131 -217
- package/dist/runtime/components/Edit/Features/Selection/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Settings/Dialog/FeatureSetting/index.vue +50 -81
- package/dist/runtime/components/Edit/Features/Settings/Dialog/FeatureSetting/index.vue.d.ts +9 -0
- package/dist/runtime/components/Edit/Features/Settings/Dialog/index.vue +73 -117
- package/dist/runtime/components/Edit/Features/Settings/Dialog/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/Settings/index.vue +41 -53
- package/dist/runtime/components/Edit/Features/Settings/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue +65 -101
- package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue.d.ts +15 -0
- package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue +71 -99
- package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/Structure/List/index.vue +17 -26
- package/dist/runtime/components/Edit/Features/Structure/List/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/Structure/index.vue +31 -40
- package/dist/runtime/components/Edit/Features/Structure/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Theme/Color/index.vue +32 -53
- package/dist/runtime/components/Edit/Features/Theme/Color/index.vue.d.ts +7 -0
- package/dist/runtime/components/Edit/Features/Theme/GeneratedCode/index.vue +7 -10
- package/dist/runtime/components/Edit/Features/Theme/GeneratedCode/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Theme/index.vue +49 -63
- package/dist/runtime/components/Edit/Features/Theme/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/TouchActionBar/Bar/index.vue +9 -10
- package/dist/runtime/components/Edit/Features/TouchActionBar/Bar/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/Features/TouchActionBar/index.vue +16 -19
- package/dist/runtime/components/Edit/Features/TouchActionBar/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +117 -172
- package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/Tour/Popup/index.vue +8 -10
- package/dist/runtime/components/Edit/Features/Tour/Popup/index.vue.d.ts +8 -0
- package/dist/runtime/components/Edit/Features/Tour/index.vue +21 -25
- package/dist/runtime/components/Edit/Features/Tour/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Transform/index.vue +80 -120
- package/dist/runtime/components/Edit/Features/Transform/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue +20 -28
- package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/Translations/index.vue +96 -139
- package/dist/runtime/components/Edit/Features/Translations/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/Validations/Overlay/Item.vue +21 -35
- package/dist/runtime/components/Edit/Features/Validations/Overlay/Item.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/Validations/Overlay/index.vue +30 -39
- package/dist/runtime/components/Edit/Features/Validations/Overlay/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue +20 -28
- package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue.d.ts +9 -0
- package/dist/runtime/components/Edit/Features/Validations/index.vue +26 -32
- package/dist/runtime/components/Edit/Features/Validations/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Features/index.vue +33 -52
- package/dist/runtime/components/Edit/Features/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Form/Group/index.vue +23 -0
- package/dist/runtime/components/Edit/Form/Group/index.vue.d.ts +20 -0
- package/dist/runtime/components/Edit/Form/Item/index.vue +5 -0
- package/dist/runtime/components/Edit/Form/Item/index.vue.d.ts +14 -0
- package/dist/runtime/components/Edit/Form/Textarea/index.vue +27 -0
- package/dist/runtime/components/Edit/Form/Textarea/index.vue.d.ts +16 -0
- package/dist/runtime/components/Edit/Form/Toggle/index.vue +21 -0
- package/dist/runtime/components/Edit/Form/Toggle/index.vue.d.ts +14 -0
- package/dist/runtime/components/Edit/FormOverlay/Header/index.vue +11 -22
- package/dist/runtime/components/Edit/FormOverlay/Header/index.vue.d.ts +18 -0
- package/dist/runtime/components/Edit/FormOverlay/index.vue +15 -21
- package/dist/runtime/components/Edit/FormOverlay/index.vue.d.ts +25 -0
- package/dist/runtime/components/Edit/Highlight/index.vue +31 -70
- package/dist/runtime/components/Edit/Highlight/index.vue.d.ts +20 -0
- package/dist/runtime/components/Edit/Icon/index.vue +11 -14
- package/dist/runtime/components/Edit/Icon/index.vue.d.ts +7 -0
- package/dist/runtime/components/Edit/InfoBox/index.vue +5 -6
- package/dist/runtime/components/Edit/InfoBox/index.vue.d.ts +5 -0
- package/dist/runtime/components/Edit/ItemIcon/index.vue +13 -13
- package/dist/runtime/components/Edit/ItemIcon/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Loading/index.vue +8 -9
- package/dist/runtime/components/Edit/Loading/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/Messages/Item/index.vue +30 -41
- package/dist/runtime/components/Edit/Messages/Item/index.vue.d.ts +11 -0
- package/dist/runtime/components/Edit/Messages/index.vue +13 -17
- package/dist/runtime/components/Edit/Messages/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Pagination/index.vue +6 -8
- package/dist/runtime/components/Edit/Pagination/index.vue.d.ts +12 -0
- package/dist/runtime/components/Edit/PreviewProvider.vue +123 -177
- package/dist/runtime/components/Edit/PreviewProvider.vue.d.ts +24 -0
- package/dist/runtime/components/Edit/RelativeTime/index.vue +19 -25
- package/dist/runtime/components/Edit/RelativeTime/index.vue.d.ts +15 -0
- package/dist/runtime/components/Edit/Resizable/index.vue +45 -55
- package/dist/runtime/components/Edit/Resizable/index.vue.d.ts +13 -0
- package/dist/runtime/components/Edit/ScaleToFit/index.vue +44 -62
- package/dist/runtime/components/Edit/ScaleToFit/index.vue.d.ts +15 -0
- package/dist/runtime/components/Edit/ScrollBoundary/index.vue +11 -27
- package/dist/runtime/components/Edit/ScrollBoundary/index.vue.d.ts +23 -0
- package/dist/runtime/components/Edit/ShortcutIndicator/index.vue +47 -59
- package/dist/runtime/components/Edit/ShortcutIndicator/index.vue.d.ts +20 -0
- package/dist/runtime/components/Edit/Sortli/index.vue +45 -59
- package/dist/runtime/components/Edit/Sortli/index.vue.d.ts +14 -0
- package/dist/runtime/components/Edit/SystemRequirements/index.vue +29 -43
- package/dist/runtime/components/Edit/SystemRequirements/index.vue.d.ts +2 -0
- package/dist/runtime/components/Edit/Toolbar/index.vue +26 -41
- package/dist/runtime/components/Edit/Toolbar/index.vue.d.ts +6 -0
- package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue +29 -51
- package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue.d.ts +20 -0
- package/dist/runtime/components/Edit/index.d.ts +5 -1
- package/dist/runtime/components/Edit/index.js +9 -1
- package/dist/runtime/composables/defineBlokkli.d.ts +2 -2
- package/dist/runtime/composables/defineBlokkli.js +29 -11
- package/dist/runtime/composables/defineBlokkliFragment.d.ts +1 -1
- package/dist/runtime/composables/defineBlokkliFragment.js +16 -24
- package/dist/runtime/css/output.css +1 -1
- package/dist/runtime/helpers/definitionProvider.d.ts +18 -0
- package/dist/runtime/helpers/definitionProvider.js +96 -0
- package/dist/runtime/helpers/domProvider.d.ts +2 -1
- package/dist/runtime/helpers/domProvider.js +6 -3
- package/dist/runtime/helpers/editComponents/index.d.ts +2 -0
- package/dist/runtime/helpers/editComponents/index.js +10 -0
- package/dist/runtime/helpers/featuresProvider.d.ts +2 -1
- package/dist/runtime/helpers/featuresProvider.js +19 -10
- package/dist/runtime/helpers/frameEventBus.d.ts +1 -1
- package/dist/runtime/helpers/imports/index.d.ts +1 -0
- package/dist/runtime/helpers/imports/index.js +44 -0
- package/dist/runtime/helpers/index.js +5 -8
- package/dist/runtime/helpers/runtimeHelpers/index.d.ts +5 -0
- package/dist/runtime/helpers/runtimeHelpers/index.js +17 -4
- package/dist/runtime/helpers/stateProvider.d.ts +1 -1
- package/dist/runtime/helpers/textProvider.d.ts +1 -1
- package/dist/runtime/helpers/themeProvider.js +4 -1
- package/dist/runtime/helpers/transform.d.ts +1 -1
- package/dist/runtime/helpers/typesProvider.d.ts +2 -2
- package/dist/runtime/helpers/uiProvider.js +4 -5
- package/dist/runtime/helpers/webgl/index.js +1 -1
- package/dist/runtime/icons/arrow-right-thin.svg +3 -0
- package/dist/runtime/public/_blokkli-assets/check.svg +6 -0
- package/dist/runtime/public/_blokkli-assets/loader.svg +1 -0
- package/dist/runtime/types/blokkOptions.d.ts +11 -2
- package/dist/runtime/types/index.d.ts +34 -14
- package/dist/shared/editor.gz_ac6uT.d.mts +431 -0
- package/dist/types.d.mts +1 -1
- package/package.json +26 -18
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -198
- package/dist/runtime/adapter/drupal/graphql/base.graphql +0 -944
- package/dist/runtime/adapter/drupal/graphqlMiddleware.d.ts +0 -2
- package/dist/runtime/adapter/drupal/graphqlMiddleware.js +0 -680
- package/dist/runtime/types/generatedModuleTypes.d.ts +0 -49
- package/dist/types.d.ts +0 -1
- /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/comments.graphql +0 -0
- /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/fragments.graphql +0 -0
- /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/search.graphql +0 -0
- /package/dist/{runtime/adapter/drupal/graphql → modules/drupal/graphql/features}/transform.graphql +0 -0
- /package/dist/runtime/{types/generatedModuleTypes.js → components/Edit/Features/Publish/Dialog/types.js} +0 -0
- /package/dist/runtime/public/{Inter.var.woff2 → _blokkli-assets/Inter.var.woff2} +0 -0
package/dist/module.mjs
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs, { promises, existsSync } from 'node:fs';
|
|
3
|
-
import { defineNuxtModule, createResolver, resolveFiles, addTemplate, addComponent, addBuildPlugin, addImports, addPlugin, updateTemplates } from '@nuxt/kit';
|
|
4
|
-
import { defu, createDefu } from 'defu';
|
|
5
|
-
import { relative } from 'pathe';
|
|
1
|
+
import { resolveFiles, createResolver, addComponent, addImports, addTemplate, addTypeTemplate, resolveAlias, defineNuxtModule, addPlugin, addBuildPlugin } from '@nuxt/kit';
|
|
6
2
|
import { createUnplugin } from 'unplugin';
|
|
7
3
|
import MagicString from 'magic-string';
|
|
8
4
|
import { walk } from 'estree-walker-ts';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { parseURL, parseQuery } from 'ufo';
|
|
7
|
+
import * as ts from 'typescript';
|
|
8
|
+
import path, { basename } from 'node:path';
|
|
9
|
+
import { dirname, relative } from 'pathe';
|
|
10
|
+
import micromatch from 'micromatch';
|
|
11
|
+
import { hash } from 'ohash';
|
|
9
12
|
import { BK_VISIBLE_LANGUAGES, BK_HIDDEN_GLOBALLY } from '../dist/runtime/helpers/symbols.js';
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import { defu, createDefu } from 'defu';
|
|
10
15
|
|
|
11
|
-
const version = "
|
|
16
|
+
const version = "2.0.0-alpha.1";
|
|
12
17
|
|
|
13
18
|
function sortObjectKeys(obj) {
|
|
14
19
|
if (Array.isArray(obj)) {
|
|
@@ -23,846 +28,915 @@ function sortObjectKeys(obj) {
|
|
|
23
28
|
}
|
|
24
29
|
return obj;
|
|
25
30
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
function toValidVariableName(input) {
|
|
32
|
+
let result = input.replace(/\W/g, "_");
|
|
33
|
+
if (/^\d/.test(result)) {
|
|
34
|
+
result = "_" + result;
|
|
35
|
+
}
|
|
36
|
+
if (result === "") {
|
|
37
|
+
result = "_empty";
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
29
40
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (v && "value" in v) {
|
|
44
|
-
return v.value;
|
|
45
|
-
}
|
|
46
|
-
}).filter(falsy)
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
}).filter(falsy)
|
|
52
|
-
);
|
|
41
|
+
function parseTsObject(tsObjectStr) {
|
|
42
|
+
const source = `(${tsObjectStr})`;
|
|
43
|
+
const result = ts.transpileModule(source, {
|
|
44
|
+
compilerOptions: {
|
|
45
|
+
target: ts.ScriptTarget.ESNext,
|
|
46
|
+
module: ts.ModuleKind.None,
|
|
47
|
+
removeComments: true
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const jsCode = result.outputText.trim();
|
|
51
|
+
const createObj = new Function(`return ${jsCode}`);
|
|
52
|
+
const object = createObj();
|
|
53
|
+
return { object, source: jsCode };
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
function extractObjectLiteral(fileContents, composables) {
|
|
56
|
+
const composablesMatch = composables.join("|");
|
|
57
|
+
const pattern = `(${composablesMatch})\\(\\s*(\\{[\\s\\S]+?\\})\\s*\\)`;
|
|
58
|
+
const rgx = new RegExp(pattern);
|
|
59
|
+
const matches = rgx.exec(fileContents);
|
|
60
|
+
if (!matches) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
return matches?.at(2);
|
|
64
|
+
}
|
|
65
|
+
function falsy(value) {
|
|
66
|
+
return value !== null && value !== void 0;
|
|
58
67
|
}
|
|
59
|
-
const DefinitionPlugin = (nuxt, composableName = "defineBlokkli") => createUnplugin(() => {
|
|
60
|
-
return {
|
|
61
|
-
name: "transform-file",
|
|
62
|
-
enforce: "post",
|
|
63
|
-
transform(source, id) {
|
|
64
|
-
if (!fileRegex.test(id)) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (!source.includes(composableName)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const s = new MagicString(source);
|
|
71
|
-
const parsed = this.parse(source, {
|
|
72
|
-
sourceType: "module",
|
|
73
|
-
ecmaVersion: "latest"
|
|
74
|
-
});
|
|
75
|
-
walk(parsed, {
|
|
76
|
-
enter: (node) => {
|
|
77
|
-
if (node.type !== "CallExpression" || node.callee.type !== "Identifier") {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const callNode = node;
|
|
81
|
-
const name = "name" in callNode.callee && callNode.callee.name;
|
|
82
|
-
if (name === composableName) {
|
|
83
|
-
const arg = callNode.arguments[0];
|
|
84
|
-
const meta = callNode.arguments[0];
|
|
85
|
-
if (arg.type === "ObjectExpression") {
|
|
86
|
-
const definition = estreeToObject(arg);
|
|
87
|
-
const runtimeDefinition = buildRuntimeDefinition(definition);
|
|
88
|
-
const start = meta.start;
|
|
89
|
-
const end = meta.end;
|
|
90
|
-
s.overwrite(start, end, JSON.stringify(runtimeDefinition));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
leave: () => {
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
if (s.hasChanged()) {
|
|
98
|
-
return {
|
|
99
|
-
code: s.toString(),
|
|
100
|
-
map: nuxt.options.sourcemap.client || nuxt.options.sourcemap.server ? s.generateMap({ hires: true }) : null
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return source;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
68
|
|
|
108
|
-
class
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
composableName;
|
|
113
|
-
fragmentComposableName;
|
|
114
|
-
buildDir;
|
|
115
|
-
imports;
|
|
116
|
-
constructor(isBuild = false, buildDir, imports) {
|
|
117
|
-
this.isBuild = isBuild;
|
|
118
|
-
this.buildDir = buildDir;
|
|
119
|
-
this.imports = imports;
|
|
120
|
-
this.composableName = "defineBlokkli";
|
|
121
|
-
this.fragmentComposableName = "defineBlokkliFragment";
|
|
69
|
+
class CollectedFile {
|
|
70
|
+
constructor(filePath, fileContents) {
|
|
71
|
+
this.filePath = filePath;
|
|
72
|
+
this.fileContents = fileContents;
|
|
122
73
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*/
|
|
126
|
-
addFiles(files) {
|
|
127
|
-
return Promise.all(files.map((v) => this.handleFile(v)));
|
|
74
|
+
async handleChange(_helper) {
|
|
75
|
+
return Promise.resolve(true);
|
|
128
76
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
77
|
+
}
|
|
78
|
+
class Collector {
|
|
79
|
+
constructor(helper) {
|
|
80
|
+
this.helper = helper;
|
|
81
|
+
this.files = /* @__PURE__ */ new Map();
|
|
82
|
+
}
|
|
83
|
+
files;
|
|
84
|
+
needsFileContents = true;
|
|
85
|
+
async addFile(filePath) {
|
|
86
|
+
if (this.needsFileContents) {
|
|
87
|
+
const contents = await this.helper.fileCache.read(filePath);
|
|
88
|
+
const file = this.createCollectedFile(filePath, contents.toString());
|
|
89
|
+
await file.handleChange(this.helper);
|
|
90
|
+
this.files.set(filePath, file);
|
|
91
|
+
} else {
|
|
92
|
+
const file = this.createCollectedFile(filePath);
|
|
93
|
+
await file.handleChange(this.helper);
|
|
94
|
+
this.files.set(filePath, file);
|
|
137
95
|
}
|
|
138
96
|
}
|
|
139
|
-
async
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return componentPath;
|
|
145
|
-
} catch {
|
|
97
|
+
async handleAdd(filePath) {
|
|
98
|
+
const applies = await this.applies(filePath);
|
|
99
|
+
if (applies) {
|
|
100
|
+
await this.addFile(filePath);
|
|
101
|
+
return true;
|
|
146
102
|
}
|
|
103
|
+
return false;
|
|
147
104
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const fileSource = await this.readFile(filePath2);
|
|
156
|
-
const extracted = this.extractSingle(fileSource, filePath2);
|
|
157
|
-
if (!extracted) {
|
|
158
|
-
if (this.definitions[filePath2]) {
|
|
159
|
-
this.definitions[filePath2] = void 0;
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
if (this.fragmentDefinitions[filePath2]) {
|
|
163
|
-
this.fragmentDefinitions[filePath2] = void 0;
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
105
|
+
async handleChange(filePath) {
|
|
106
|
+
const applies = await this.applies(filePath);
|
|
107
|
+
if (!applies) {
|
|
108
|
+
return this.handleUnlink(filePath);
|
|
109
|
+
}
|
|
110
|
+
const file = this.files.get(filePath);
|
|
111
|
+
if (!file) {
|
|
166
112
|
return false;
|
|
167
113
|
}
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (this.definitions[filePath2] && this.definitions[filePath2]?.source === extracted.source) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
const extension = path.extname(filePath2);
|
|
176
|
-
const componentFileName = path.basename(filePath2, extension);
|
|
177
|
-
this.definitions[filePath2] = {
|
|
178
|
-
filePath: filePath2,
|
|
179
|
-
definition: extracted.definition,
|
|
180
|
-
icon,
|
|
181
|
-
proxyComponent,
|
|
182
|
-
diffComponent,
|
|
183
|
-
chunkName: this.isBuild ? extracted.definition.chunkName || "global" : "global",
|
|
184
|
-
componentName: "BlokkliComponent_" + extracted.definition.bundle + "_" + componentFileName,
|
|
185
|
-
source: extracted.source,
|
|
186
|
-
fileSource,
|
|
187
|
-
hasBlokkliField: fileSource.includes("<BlokkliField") || fileSource.includes("<blokkli-field") || fileSource.includes(':is="BlokkliField"')
|
|
188
|
-
};
|
|
189
|
-
} else if ("name" in extracted.definition) {
|
|
190
|
-
if (this.fragmentDefinitions[filePath2] && this.fragmentDefinitions[filePath2]?.source === extracted.source) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
this.fragmentDefinitions[filePath2] = {
|
|
194
|
-
filePath: filePath2,
|
|
195
|
-
definition: extracted.definition,
|
|
196
|
-
chunkName: this.isBuild ? extracted.definition.chunkName || "global" : "global",
|
|
197
|
-
componentName: "BlokkliFragmentComponent_" + extracted.definition.name,
|
|
198
|
-
source: extracted.source,
|
|
199
|
-
fileSource
|
|
200
|
-
};
|
|
114
|
+
if (this.needsFileContents) {
|
|
115
|
+
const contents = await this.helper.fileCache.read(filePath);
|
|
116
|
+
file.fileContents = contents.toString();
|
|
117
|
+
return await file.handleChange(this.helper);
|
|
201
118
|
}
|
|
202
119
|
return true;
|
|
203
120
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const pattern = `(${this.composableName}|${this.fragmentComposableName})\\((\\{.+?\\})\\)`;
|
|
209
|
-
const rgx = new RegExp(pattern, "gms");
|
|
210
|
-
const source = rgx.exec(code)?.[2];
|
|
211
|
-
if (source) {
|
|
212
|
-
try {
|
|
213
|
-
const definition = eval(`(${source})`);
|
|
214
|
-
return { definition, source };
|
|
215
|
-
} catch (e) {
|
|
216
|
-
console.error(
|
|
217
|
-
`Failed to parse component "${filePath}": ${this.composableName} does not contain a valid object literal. No variables and methods are allowed inside ${this.composableName}().`,
|
|
218
|
-
e
|
|
219
|
-
);
|
|
220
|
-
}
|
|
121
|
+
handleUnlink(filePath) {
|
|
122
|
+
if (this.files.has(filePath)) {
|
|
123
|
+
this.files.delete(filePath);
|
|
124
|
+
return true;
|
|
221
125
|
}
|
|
126
|
+
return false;
|
|
222
127
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
128
|
+
handleAddDir() {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
handleUnlinkDir(folderPath) {
|
|
132
|
+
const allKeys = [...this.files.keys()];
|
|
133
|
+
const toRemove = allKeys.filter((filePath) => filePath.includes(folderPath));
|
|
134
|
+
if (toRemove.length) {
|
|
135
|
+
toRemove.forEach((key) => this.files.delete(key));
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
async handleWatchEvent(event, filePath) {
|
|
141
|
+
let hasChanged = false;
|
|
142
|
+
if (event === "add") {
|
|
143
|
+
hasChanged = await this.handleAdd(filePath);
|
|
144
|
+
} else if (event === "change") {
|
|
145
|
+
hasChanged = await this.handleChange(filePath);
|
|
146
|
+
} else if (event === "unlink") {
|
|
147
|
+
hasChanged = await this.handleUnlink(filePath);
|
|
148
|
+
} else if (event === "addDir") {
|
|
149
|
+
hasChanged = this.handleAddDir();
|
|
150
|
+
} else if (event === "unlinkDir") {
|
|
151
|
+
hasChanged = this.handleUnlinkDir(filePath);
|
|
152
|
+
}
|
|
153
|
+
return { hasChanged };
|
|
230
154
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Generate the template.
|
|
233
|
-
*/
|
|
234
|
-
generateDefinitionTemplate(globalOptions = {}) {
|
|
235
|
-
const definitionDeclarations = Object.values(this.definitions).filter(falsy).map((v) => {
|
|
236
|
-
return `const ${v.componentName}: DefinitionItem = ${v.source}`;
|
|
237
|
-
}, {});
|
|
238
|
-
const allDefinitions = Object.values(this.definitions).filter(falsy).reduce((acc, v) => {
|
|
239
|
-
const bundle = v.definition.bundle;
|
|
240
|
-
const renderFor = v.definition.renderFor;
|
|
241
|
-
if (renderFor) {
|
|
242
|
-
const renderForList = Array.isArray(renderFor) ? renderFor : [renderFor];
|
|
243
|
-
renderForList.forEach((entry) => {
|
|
244
|
-
if ("parentBundle" in entry) {
|
|
245
|
-
acc.push(
|
|
246
|
-
`${bundle}__parent_block_${entry.parentBundle}: ${v.componentName}`
|
|
247
|
-
);
|
|
248
|
-
} else if ("fieldList" in entry) {
|
|
249
|
-
acc.push(
|
|
250
|
-
`${bundle}__field_list_type_${entry.fieldList}: ${v.componentName}`
|
|
251
|
-
);
|
|
252
|
-
} else if ("fieldListType" in entry) {
|
|
253
|
-
acc.push(
|
|
254
|
-
`${bundle}__field_list_type_${entry.fieldListType}: ${v.componentName}`
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
} else {
|
|
259
|
-
acc.push(`${bundle}: ${v.componentName}`);
|
|
260
|
-
}
|
|
261
|
-
return acc;
|
|
262
|
-
}, []);
|
|
263
|
-
const allFragmentDefinitions = Object.values(this.fragmentDefinitions).filter(falsy).map((v) => {
|
|
264
|
-
return `${v.definition.name}: ${v.source}`;
|
|
265
|
-
});
|
|
266
|
-
const icons = Object.values(this.definitions).filter(falsy).reduce((acc, v) => {
|
|
267
|
-
if (v.icon) {
|
|
268
|
-
acc[v.definition.bundle] = v.icon;
|
|
269
|
-
}
|
|
270
|
-
return acc;
|
|
271
|
-
}, {});
|
|
272
|
-
const allFragmentNames = Object.values(this.fragmentDefinitions).filter(falsy).map((v) => `'${v.definition.name}'`).join(" | ");
|
|
273
|
-
return `
|
|
274
|
-
import type { GlobalOptionsKey, ValidFieldListTypes, BlockBundleWithNested } from './generated-types'
|
|
275
|
-
import type { BlockDefinitionInput, BlockDefinitionOptionsInput, FragmentDefinitionInput } from '${this.imports.TYPES}'
|
|
276
|
-
export const globalOptions = ${JSON.stringify(globalOptions, null, 2)} as const
|
|
277
|
-
|
|
278
|
-
type DefinitionItem = BlockDefinitionInput<BlockDefinitionOptionsInput, GlobalOptionsKey[]>
|
|
279
|
-
|
|
280
|
-
${definitionDeclarations.join("\n")}
|
|
281
|
-
|
|
282
|
-
export const icons: Record<string, string> = ${JSON.stringify(icons)}
|
|
283
|
-
|
|
284
|
-
export const definitionsMap: Record<string, DefinitionItem> = {
|
|
285
|
-
${allDefinitions.join(",\n")}
|
|
286
155
|
}
|
|
287
156
|
|
|
288
|
-
|
|
289
|
-
|
|
157
|
+
const DEFINE_BLOKKLI = "defineBlokkli";
|
|
158
|
+
const DEFINE_BLOKKLI_FRAGMENT = "defineBlokkliFragment";
|
|
159
|
+
function isEditComponent(filePath) {
|
|
160
|
+
return filePath.endsWith("/diff.vue") || filePath.endsWith("/proxy.vue");
|
|
290
161
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Get the block definition for the given field and parent context.
|
|
299
|
-
*/
|
|
300
|
-
export function getDefinition(bundle: string, fieldListType: ValidFieldListTypes, parentBundle?: BlockBundleWithNested): BlockDefinitionInput<Record<string, any>, GlobalOptionsKey[]>|undefined {
|
|
301
|
-
const forFieldListType = bundle + '__field_list_type_' + fieldListType
|
|
302
|
-
if (definitionsMap[forFieldListType]) {
|
|
303
|
-
return definitionsMap[forFieldListType]
|
|
162
|
+
function isBlock(definition) {
|
|
163
|
+
return "bundle" in definition;
|
|
164
|
+
}
|
|
165
|
+
function getVariations(definition) {
|
|
166
|
+
if (!definition) {
|
|
167
|
+
return [];
|
|
304
168
|
}
|
|
305
|
-
if (
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
return
|
|
169
|
+
if (isBlock(definition)) {
|
|
170
|
+
const bundle = definition.bundle;
|
|
171
|
+
if (!definition.renderFor) {
|
|
172
|
+
return ["block:" + bundle];
|
|
309
173
|
}
|
|
174
|
+
const renderFor = Array.isArray(definition.renderFor) ? definition.renderFor : [definition.renderFor];
|
|
175
|
+
return renderFor.map((v) => {
|
|
176
|
+
if ("parentBundle" in v) {
|
|
177
|
+
return `block:${bundle}__p:${v.parentBundle}`;
|
|
178
|
+
} else if ("fieldList" in v) {
|
|
179
|
+
return `block:${bundle}__f:${v.fieldList}`;
|
|
180
|
+
} else {
|
|
181
|
+
return `block:${bundle}__f:${v.fieldListType}`;
|
|
182
|
+
}
|
|
183
|
+
}).sort();
|
|
310
184
|
}
|
|
311
|
-
|
|
312
|
-
return definitionsMap[bundle]
|
|
185
|
+
return [`fragment:${definition.name}`];
|
|
313
186
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
187
|
+
function getIdentifier(definition) {
|
|
188
|
+
const type = isBlock(definition) ? "b" : "f";
|
|
189
|
+
const name = isBlock(definition) ? definition.bundle : definition.name;
|
|
190
|
+
return toValidVariableName(
|
|
191
|
+
type + "_" + hash(name + getVariations(definition).join("__"))
|
|
192
|
+
);
|
|
320
193
|
}
|
|
321
|
-
|
|
322
|
-
|
|
194
|
+
class CollectedBlockFile extends CollectedFile {
|
|
195
|
+
folder = "";
|
|
196
|
+
iconPath = null;
|
|
197
|
+
iconContents = null;
|
|
198
|
+
diffComponentPath = null;
|
|
199
|
+
proxyComponentPath = null;
|
|
200
|
+
type = null;
|
|
201
|
+
definition = null;
|
|
202
|
+
definitionSource = null;
|
|
203
|
+
hasBlokkliField = false;
|
|
204
|
+
identifier = "";
|
|
205
|
+
chunkName = "global";
|
|
206
|
+
variations = [];
|
|
207
|
+
objectLiteralString = "";
|
|
208
|
+
hasSiblingFile(name, helper) {
|
|
209
|
+
const siblingFilePath = path.join(this.folder, "/" + name);
|
|
210
|
+
if (helper.fileCache.fileExists(siblingFilePath)) {
|
|
211
|
+
return siblingFilePath;
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
323
214
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
215
|
+
async handleChange(helper) {
|
|
216
|
+
this.folder = dirname(this.filePath);
|
|
217
|
+
const diffComponentPath = this.hasSiblingFile("diff.vue", helper);
|
|
218
|
+
const proxyComponentPath = this.hasSiblingFile("proxy.vue", helper);
|
|
219
|
+
const objectLiteralString = extractObjectLiteral(this.fileContents, [
|
|
220
|
+
DEFINE_BLOKKLI,
|
|
221
|
+
DEFINE_BLOKKLI_FRAGMENT
|
|
222
|
+
]);
|
|
223
|
+
if (objectLiteralString === this.objectLiteralString && diffComponentPath === this.diffComponentPath && proxyComponentPath === this.proxyComponentPath) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
this.objectLiteralString = objectLiteralString || "";
|
|
227
|
+
this.diffComponentPath = diffComponentPath;
|
|
228
|
+
this.proxyComponentPath = proxyComponentPath;
|
|
229
|
+
try {
|
|
230
|
+
if (this.objectLiteralString) {
|
|
231
|
+
const result = parseTsObject(
|
|
232
|
+
this.objectLiteralString
|
|
233
|
+
);
|
|
234
|
+
this.definition = result.object;
|
|
235
|
+
this.definitionSource = result.source;
|
|
331
236
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
237
|
+
} catch (e) {
|
|
238
|
+
console.error(
|
|
239
|
+
`Failed to parse component "${this.filePath}": The composabe does not contain a valid object literal. No variables and methods are allowed inside the composable.`,
|
|
240
|
+
e
|
|
335
241
|
);
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
this.hasBlokkliField = this.fileContents.includes("<BlokkliField") || this.fileContents.includes("<blokkli-field") || this.fileContents.includes(':is="BlokkliField"');
|
|
245
|
+
this.chunkName = this.definition?.chunkName || "global";
|
|
246
|
+
this.identifier = this.definition ? getIdentifier(this.definition) : "";
|
|
247
|
+
if (!this.definition) {
|
|
248
|
+
this.type = null;
|
|
249
|
+
} else if (isBlock(this.definition)) {
|
|
250
|
+
if (this.definition.renderFor) {
|
|
251
|
+
this.type = "context";
|
|
252
|
+
} else {
|
|
253
|
+
this.type = "main";
|
|
342
254
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
255
|
+
} else {
|
|
256
|
+
this.type = "fragment";
|
|
257
|
+
}
|
|
258
|
+
if (this.type === "main") {
|
|
259
|
+
this.iconPath = this.hasSiblingFile("icon.svg", helper);
|
|
260
|
+
if (this.iconPath) {
|
|
261
|
+
this.iconContents = await helper.fileCache.read(this.iconPath);
|
|
348
262
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
263
|
+
} else {
|
|
264
|
+
this.iconPath = null;
|
|
265
|
+
this.iconContents = null;
|
|
266
|
+
}
|
|
267
|
+
this.variations = getVariations(this.definition);
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
class BlockCollector extends Collector {
|
|
272
|
+
patterns;
|
|
273
|
+
constructor(helper) {
|
|
274
|
+
super(helper);
|
|
275
|
+
this.patterns = (helper.options.pattern || []).map((pattern) => {
|
|
276
|
+
if (pattern.startsWith("/")) {
|
|
277
|
+
return pattern;
|
|
278
|
+
}
|
|
279
|
+
return helper.resolvers.src.resolve(pattern);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
async init() {
|
|
283
|
+
const files = await resolveFiles(
|
|
284
|
+
this.helper.nuxt.options.srcDir,
|
|
285
|
+
this.patterns
|
|
286
|
+
);
|
|
287
|
+
const promises = [];
|
|
288
|
+
for (const filePath of files) {
|
|
289
|
+
const applies = await this.applies(filePath);
|
|
290
|
+
if (applies) {
|
|
291
|
+
promises.push(this.addFile(filePath));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
await Promise.all(promises);
|
|
295
|
+
}
|
|
296
|
+
runHooks() {
|
|
297
|
+
return this.helper.nuxt.hooks.callHook("blokkli:alter-blocks", {
|
|
298
|
+
blocks: [...this.files.values()]
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
createCollectedFile(filePath, fileContents = "") {
|
|
302
|
+
return new CollectedBlockFile(filePath, fileContents);
|
|
303
|
+
}
|
|
304
|
+
findBlockForFolderFile(iconPath) {
|
|
305
|
+
for (const file of this.files.values()) {
|
|
306
|
+
if (file.iconPath === iconPath || file.proxyComponentPath === iconPath || file.diffComponentPath === iconPath) {
|
|
307
|
+
return file.filePath;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
async handleAdd(filePath) {
|
|
313
|
+
if (isEditComponent(filePath)) {
|
|
314
|
+
const folder = dirname(filePath);
|
|
315
|
+
for (const file of this.files.values()) {
|
|
316
|
+
if (file.folder === folder) {
|
|
317
|
+
return super.handleChange(file.filePath);
|
|
374
318
|
}
|
|
375
|
-
}
|
|
319
|
+
}
|
|
376
320
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
321
|
+
return super.handleAdd(filePath);
|
|
322
|
+
}
|
|
323
|
+
async handleUnlink(filePath) {
|
|
324
|
+
if (isEditComponent(filePath)) {
|
|
325
|
+
const folder = dirname(filePath);
|
|
326
|
+
for (const file of this.files.values()) {
|
|
327
|
+
if (file.folder === folder) {
|
|
328
|
+
return super.handleChange(file.filePath);
|
|
329
|
+
}
|
|
380
330
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
331
|
+
}
|
|
332
|
+
return super.handleUnlink(filePath);
|
|
333
|
+
}
|
|
334
|
+
async handleChange(filePath) {
|
|
335
|
+
if (filePath.includes("icon.svg")) {
|
|
336
|
+
const matchingBlockFilePath = this.findBlockForFolderFile(filePath);
|
|
337
|
+
if (matchingBlockFilePath) {
|
|
338
|
+
return this.handleChange(matchingBlockFilePath);
|
|
385
339
|
}
|
|
386
|
-
return
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
return super.handleChange(filePath);
|
|
343
|
+
}
|
|
344
|
+
async applies(filePath) {
|
|
345
|
+
if (!filePath.endsWith(".vue")) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
if (!micromatch.isMatch(filePath, this.patterns)) {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
if (isEditComponent(filePath)) {
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
const content = await this.helper.fileCache.read(filePath);
|
|
355
|
+
return content.includes(DEFINE_BLOKKLI) || content.includes(DEFINE_BLOKKLI_FRAGMENT);
|
|
356
|
+
}
|
|
357
|
+
getDependencyTypes() {
|
|
358
|
+
return ["block-content", "block-path"];
|
|
359
|
+
}
|
|
399
360
|
}
|
|
400
361
|
|
|
401
|
-
|
|
402
|
-
|
|
362
|
+
function isVue(id, opts = {}) {
|
|
363
|
+
const { search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
364
|
+
if (id.endsWith(".vue") && !search) {
|
|
365
|
+
return true;
|
|
403
366
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
imports,
|
|
420
|
-
maps
|
|
421
|
-
};
|
|
422
|
-
};
|
|
423
|
-
const proxy = buildContextComponents("proxyComponent");
|
|
424
|
-
const diff = buildContextComponents("diffComponent");
|
|
425
|
-
return `
|
|
426
|
-
${proxy.imports}
|
|
427
|
-
${diff.imports}
|
|
428
|
-
|
|
429
|
-
const PROXY_COMPONENTS: Record<string, any> = {
|
|
430
|
-
${proxy.maps}
|
|
367
|
+
if (!search) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
const query = parseQuery(search);
|
|
371
|
+
if (query.nuxt_component) {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
if (query.macro && (search === "?macro=true" || !opts.type || opts.type.includes("script"))) {
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
const type = "setup" in query ? "script" : query.type;
|
|
378
|
+
if (!("vue" in query) || opts.type && !opts.type.includes(type)) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
return true;
|
|
431
382
|
}
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
383
|
+
function generateRuntimeArg(definition) {
|
|
384
|
+
const name = isBlock(definition) ? definition.bundle : definition.name;
|
|
385
|
+
return `${name}::${getIdentifier(definition)}`;
|
|
435
386
|
}
|
|
387
|
+
const RuntimeDefinitionPlugin = (nuxt, composableName) => {
|
|
388
|
+
const cache = /* @__PURE__ */ new Map();
|
|
389
|
+
function extract(source) {
|
|
390
|
+
const fromCache = cache.get(source);
|
|
391
|
+
if (fromCache) {
|
|
392
|
+
return fromCache;
|
|
393
|
+
}
|
|
394
|
+
const definition = parseTsObject(source);
|
|
395
|
+
if (definition.object) {
|
|
396
|
+
cache.set(source, definition.object);
|
|
397
|
+
return definition.object;
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
return createUnplugin(() => {
|
|
402
|
+
return {
|
|
403
|
+
name: "blokkli:runtime-definition",
|
|
404
|
+
enforce: "post",
|
|
405
|
+
transformInclude(id) {
|
|
406
|
+
return isVue(id);
|
|
407
|
+
},
|
|
408
|
+
transform(source) {
|
|
409
|
+
if (!source.includes(composableName)) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const s = new MagicString(source);
|
|
413
|
+
const parsed = this.parse(source, {
|
|
414
|
+
sourceType: "module",
|
|
415
|
+
ecmaVersion: "latest"
|
|
416
|
+
});
|
|
417
|
+
walk(parsed, {
|
|
418
|
+
enter: (node) => {
|
|
419
|
+
if (node.type !== "CallExpression" || node.callee.type !== "Identifier") {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
const callNode = node;
|
|
423
|
+
const name = "name" in callNode.callee && callNode.callee.name;
|
|
424
|
+
if (name === composableName) {
|
|
425
|
+
const arg = callNode.arguments[0];
|
|
426
|
+
if (!arg) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const meta = callNode.arguments[0];
|
|
430
|
+
if (arg.type === "ObjectExpression") {
|
|
431
|
+
const start = meta.start;
|
|
432
|
+
const end = meta.end;
|
|
433
|
+
const objectSource = s.slice(start, end);
|
|
434
|
+
const object = extract(objectSource);
|
|
435
|
+
if (object) {
|
|
436
|
+
const arg2 = generateRuntimeArg(object);
|
|
437
|
+
s.overwrite(start, end, `"${arg2}"`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
leave: () => {
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
if (s.hasChanged()) {
|
|
446
|
+
return {
|
|
447
|
+
code: s.toString(),
|
|
448
|
+
map: nuxt.options.sourcemap.client || nuxt.options.sourcemap.server ? s.generateMap({ hires: true }) : null
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
});
|
|
454
|
+
};
|
|
436
455
|
|
|
437
|
-
|
|
438
|
-
|
|
456
|
+
class IconCollector extends Collector {
|
|
457
|
+
needsFileContents = false;
|
|
458
|
+
srcFromModule;
|
|
459
|
+
constructor(helper) {
|
|
460
|
+
super(helper);
|
|
461
|
+
this.srcFromModule = helper.resolvers.module.resolve("./runtime/icons");
|
|
462
|
+
}
|
|
463
|
+
async init() {
|
|
464
|
+
const srcFromModule = this.helper.resolvers.module.resolve("./runtime/icons");
|
|
465
|
+
const filesModule = await resolveFiles(srcFromModule, "*.svg");
|
|
466
|
+
const filesApp = await resolveFiles(
|
|
467
|
+
this.helper.paths.srcDir,
|
|
468
|
+
"**/icon-blokkli-*.svg"
|
|
469
|
+
);
|
|
470
|
+
const allFiles = [...filesModule, ...filesApp];
|
|
471
|
+
await Promise.all(allFiles.map((filePath) => this.addFile(filePath)));
|
|
472
|
+
}
|
|
473
|
+
runHooks() {
|
|
474
|
+
return this.helper.nuxt.hooks.callHook("blokkli:alter-icons", {
|
|
475
|
+
icons: [...this.files.values()]
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
applies(filePath) {
|
|
479
|
+
return Promise.resolve(
|
|
480
|
+
filePath.startsWith(this.srcFromModule) || micromatch.isMatch(filePath, "icon-blokkli-*.svg")
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
getDependencyTypes() {
|
|
484
|
+
return ["icons"];
|
|
485
|
+
}
|
|
486
|
+
createCollectedFile(filePath, fileContents = "") {
|
|
487
|
+
return new CollectedFile(filePath, fileContents);
|
|
488
|
+
}
|
|
439
489
|
}
|
|
440
490
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
491
|
+
class FileCache {
|
|
492
|
+
cache = /* @__PURE__ */ new Map();
|
|
493
|
+
existingFiles = /* @__PURE__ */ new Set();
|
|
494
|
+
/**
|
|
495
|
+
* Read a file from disk.
|
|
496
|
+
*/
|
|
497
|
+
async read(filePath) {
|
|
498
|
+
const existing = this.cache.get(filePath);
|
|
499
|
+
if (existing) {
|
|
500
|
+
return existing;
|
|
501
|
+
}
|
|
502
|
+
const buffer = await fs.promises.readFile(filePath);
|
|
503
|
+
const content = buffer.toString();
|
|
504
|
+
this.cache.set(filePath, content);
|
|
505
|
+
return content;
|
|
445
506
|
}
|
|
446
507
|
/**
|
|
447
|
-
*
|
|
508
|
+
* Delete a file.
|
|
448
509
|
*/
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
const existing = acc[v.definition.bundle] || {};
|
|
452
|
-
acc[v.definition.bundle] = defu(existing, v.definition.options || {});
|
|
453
|
-
const globalOptionKeys = v.definition.globalOptions || [];
|
|
454
|
-
globalOptionKeys.forEach((name) => {
|
|
455
|
-
if (globalOptions[name]) {
|
|
456
|
-
acc[v.definition.bundle][name] = globalOptions[name];
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
return acc;
|
|
460
|
-
}, {});
|
|
461
|
-
const sorted = sortObjectKeys(schema);
|
|
462
|
-
return JSON.stringify(sorted, null, 2);
|
|
510
|
+
delete(filePath) {
|
|
511
|
+
this.cache.delete(filePath);
|
|
463
512
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
513
|
+
/**
|
|
514
|
+
* Check if a file exists.
|
|
515
|
+
*/
|
|
516
|
+
fileExists(filePath) {
|
|
517
|
+
if (this.existingFiles.has(filePath)) {
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
const exists = fs.existsSync(filePath);
|
|
521
|
+
if (exists) {
|
|
522
|
+
this.existingFiles.add(filePath);
|
|
523
|
+
}
|
|
524
|
+
return exists;
|
|
471
525
|
}
|
|
472
526
|
/**
|
|
473
|
-
*
|
|
527
|
+
* Handles the builder watch event.
|
|
474
528
|
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
(
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
type: BlockOptionDefinition['type']
|
|
492
|
-
default: any
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
export const bundlesWithVisibleLanguage: string[] = ${JSON.stringify(this.getBundlesWithGlobalOptions(BK_VISIBLE_LANGUAGES))}
|
|
496
|
-
export const bundlesWithHiddenGlobally: string[] = ${JSON.stringify(this.getBundlesWithGlobalOptions(BK_HIDDEN_GLOBALLY))}
|
|
497
|
-
|
|
498
|
-
export const globalOptionsDefaults: Record<string, GlobalOptionsDefaults> = ${JSON.stringify(
|
|
499
|
-
defaults,
|
|
500
|
-
null,
|
|
501
|
-
2
|
|
502
|
-
)} as const`;
|
|
503
|
-
}
|
|
504
|
-
generateTypesTemplate(globalOptions, chunkNames, fieldListTypes, getBundlePropsType) {
|
|
505
|
-
const allDefintions = Object.values(
|
|
506
|
-
this.definitions
|
|
507
|
-
).map((v) => v?.definition).filter(falsy);
|
|
508
|
-
const validChunkNames = chunkNames.map((v) => {
|
|
509
|
-
return `'${v}'`;
|
|
510
|
-
}).join(" | ");
|
|
511
|
-
const validFieldListTypes = fieldListTypes.map((v) => {
|
|
512
|
-
return `'${v}'`;
|
|
513
|
-
}).join(" | ");
|
|
514
|
-
const validGlobalOptions = Object.keys(globalOptions).map((v) => {
|
|
515
|
-
return `'${v}'`;
|
|
516
|
-
}).join(" | ");
|
|
517
|
-
const blockBundlesWithNested = Object.values(this.definitions).filter(falsy).filter((v) => v.hasBlokkliField).map((v) => {
|
|
518
|
-
return `'${v.definition.bundle}'`;
|
|
519
|
-
}).join(" | ");
|
|
520
|
-
const validBlockBundles = allDefintions.filter((v) => v.bundle !== "from_library").map((v) => {
|
|
521
|
-
return `'${v.bundle}'`;
|
|
522
|
-
}).join(" | ");
|
|
523
|
-
function getOptionTypes(definition2) {
|
|
524
|
-
const definedOptions = definition2.options || {};
|
|
525
|
-
const blockGlobalOptions = definition2.globalOptions || [];
|
|
526
|
-
blockGlobalOptions.forEach((key) => {
|
|
527
|
-
if (globalOptions[key]) {
|
|
528
|
-
definedOptions[key] = globalOptions[key];
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
const options = Object.entries(definedOptions || {}).map(([key, option]) => {
|
|
532
|
-
if (option.type === "text") {
|
|
533
|
-
return `${key}: string | undefined`;
|
|
534
|
-
} else if (option.type === "checkbox") {
|
|
535
|
-
return `${key}: '1' | '0' | undefined`;
|
|
536
|
-
} else if (option.type === "radios" || option.type === "checkboxes") {
|
|
537
|
-
return `${key}: string | undefined`;
|
|
538
|
-
} else if (option.type === "color") {
|
|
539
|
-
return `${key}: string | undefined`;
|
|
540
|
-
} else if (option.type === "range" || option.type === "number") {
|
|
541
|
-
return `${key}: number | string | undefined`;
|
|
542
|
-
}
|
|
543
|
-
}).join("\n ");
|
|
544
|
-
return `{
|
|
545
|
-
${options}
|
|
546
|
-
}`;
|
|
547
|
-
}
|
|
548
|
-
const propTypeImports = {};
|
|
549
|
-
const typedFieldListItems = [];
|
|
550
|
-
const definitions = Object.entries(this.definitions);
|
|
551
|
-
const mappedGetBundlePropsType = (bundle, definition2) => {
|
|
552
|
-
if (bundle === "from_library" || bundle === "blokkli_fragment") {
|
|
553
|
-
return {
|
|
554
|
-
typeName: "Props",
|
|
555
|
-
from: definition2.filePath
|
|
556
|
-
};
|
|
557
|
-
} else if (getBundlePropsType) {
|
|
558
|
-
return getBundlePropsType(bundle, definition2);
|
|
559
|
-
}
|
|
560
|
-
return null;
|
|
561
|
-
};
|
|
562
|
-
for (let i = 0; i < definitions.length; i++) {
|
|
563
|
-
const [_, definition2] = definitions[i];
|
|
564
|
-
if (!definition2) {
|
|
565
|
-
continue;
|
|
566
|
-
}
|
|
567
|
-
if (definition2.definition.renderFor) {
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
const bundle = definition2.definition.bundle;
|
|
571
|
-
const options = getOptionTypes(definition2.definition);
|
|
572
|
-
const generatedTypeName = `FieldListItem_${bundle}`;
|
|
573
|
-
const lines = [` bundle: '${bundle}'`, `options: ${options}`];
|
|
574
|
-
const bundlePropsType = mappedGetBundlePropsType(bundle, definition2);
|
|
575
|
-
if (bundlePropsType) {
|
|
576
|
-
const { typeName, from } = bundlePropsType;
|
|
577
|
-
if (!propTypeImports[from]) {
|
|
578
|
-
propTypeImports[from] = [];
|
|
529
|
+
async handleWatchEvent(event, filePath) {
|
|
530
|
+
if (event === "add") {
|
|
531
|
+
this.existingFiles.add(filePath);
|
|
532
|
+
this.cache.delete(filePath);
|
|
533
|
+
} else if (event === "change") {
|
|
534
|
+
this.existingFiles.add(filePath);
|
|
535
|
+
this.cache.delete(filePath);
|
|
536
|
+
} else if (event === "unlink") {
|
|
537
|
+
this.existingFiles.delete(filePath);
|
|
538
|
+
this.cache.delete(filePath);
|
|
539
|
+
} else if (event === "unlinkDir") {
|
|
540
|
+
const filePaths = [...this.existingFiles.keys()];
|
|
541
|
+
filePaths.forEach((v) => {
|
|
542
|
+
if (v.startsWith(filePath)) {
|
|
543
|
+
this.existingFiles.delete(v);
|
|
544
|
+
this.cache.delete(v);
|
|
579
545
|
}
|
|
580
|
-
propTypeImports[from].push({ bundle, typeName });
|
|
581
|
-
lines.push(`props: Bundle_${bundle}_Props`);
|
|
582
|
-
}
|
|
583
|
-
const typeDefinition = `
|
|
584
|
-
type ${generatedTypeName} = {
|
|
585
|
-
${lines.join("\n ")}
|
|
586
|
-
}`;
|
|
587
|
-
typedFieldListItems.push({
|
|
588
|
-
typeName: generatedTypeName,
|
|
589
|
-
typeDefinition
|
|
590
546
|
});
|
|
591
547
|
}
|
|
592
|
-
const propTypeImportStatements = Object.entries(propTypeImports).map(([from, items]) => {
|
|
593
|
-
const imports = items.map((v) => {
|
|
594
|
-
return `${v.typeName} as Bundle_${v.bundle}_Props`;
|
|
595
|
-
}).join(",\n ");
|
|
596
|
-
const importPath = this.toBuildRelativePath(from);
|
|
597
|
-
return `import type {
|
|
598
|
-
${imports}
|
|
599
|
-
} from '${importPath}'`;
|
|
600
|
-
}).join("\n");
|
|
601
|
-
return `
|
|
602
|
-
${propTypeImportStatements}
|
|
603
|
-
import type { FieldListItem } from "${this.imports.TYPES}"
|
|
604
|
-
|
|
605
|
-
export type ValidFieldListTypes = ${validFieldListTypes}
|
|
606
|
-
|
|
607
|
-
export type BlockBundle = ${validBlockBundles || `''`}
|
|
608
|
-
|
|
609
|
-
export type BlockBundleWithNested = ${blockBundlesWithNested || `''`}
|
|
610
|
-
|
|
611
|
-
export type ValidChunkNames = ${validChunkNames}
|
|
612
|
-
|
|
613
|
-
export type GlobalOptionsKey = ${validGlobalOptions || "never"}
|
|
614
|
-
|
|
615
|
-
export type ValidGlobalConfigKeys = Array<GlobalOptionsKey>
|
|
616
|
-
|
|
617
|
-
${typedFieldListItems.map((v) => v.typeDefinition).join("\n\n")}
|
|
618
|
-
|
|
619
|
-
export type FieldListItemTyped = Omit<FieldListItem, 'props'> & (${typedFieldListItems.map((v) => v.typeName).join(" | ")})
|
|
620
|
-
export type FieldListItemTypedArray = Array<FieldListItemTyped>
|
|
621
|
-
`;
|
|
622
548
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function onlyUnique(value, index, self) {
|
|
552
|
+
return self.indexOf(value) === index;
|
|
553
|
+
}
|
|
554
|
+
class ModuleHelper {
|
|
555
|
+
constructor(nuxt, moduleUrl, providedOptions) {
|
|
556
|
+
this.nuxt = nuxt;
|
|
557
|
+
this.isDev = nuxt.options.dev;
|
|
558
|
+
this.isModuleBuild = false;
|
|
559
|
+
this.fileCache = new FileCache();
|
|
560
|
+
this.resolvers = {
|
|
561
|
+
module: createResolver(moduleUrl),
|
|
562
|
+
build: createResolver(nuxt.options.buildDir),
|
|
563
|
+
src: createResolver(nuxt.options.srcDir),
|
|
564
|
+
app: createResolver(nuxt.options.dir.app)
|
|
565
|
+
};
|
|
566
|
+
this.paths = {
|
|
567
|
+
blokkliBuildDir: this.resolvers.build.resolve("blokkli"),
|
|
568
|
+
srcDir: nuxt.options.srcDir,
|
|
569
|
+
editAdapter: this.findEditAdapterPath()
|
|
570
|
+
};
|
|
571
|
+
this.relativePaths = {
|
|
572
|
+
TYPES: relative(
|
|
573
|
+
this.paths.blokkliBuildDir,
|
|
574
|
+
this.resolvers.module.resolve("./runtime/types/index.ts")
|
|
575
|
+
),
|
|
576
|
+
CONSTANTS: relative(
|
|
577
|
+
this.paths.blokkliBuildDir,
|
|
578
|
+
this.resolvers.module.resolve("./runtime/constants/index.ts")
|
|
579
|
+
),
|
|
580
|
+
ADAPTER: relative(
|
|
581
|
+
this.paths.blokkliBuildDir,
|
|
582
|
+
this.resolvers.module.resolve("./runtime/adapter/index.ts")
|
|
583
|
+
),
|
|
584
|
+
TYPES_THEME: relative(
|
|
585
|
+
this.paths.blokkliBuildDir,
|
|
586
|
+
this.resolvers.module.resolve("./runtime/types/theme.ts")
|
|
587
|
+
),
|
|
588
|
+
TYPES_BLOKK_OPTIONS: relative(
|
|
589
|
+
this.paths.blokkliBuildDir,
|
|
590
|
+
this.resolvers.module.resolve("./runtime/types/blokkOptions.ts")
|
|
591
|
+
)
|
|
592
|
+
};
|
|
593
|
+
const pattern = providedOptions.pattern || [];
|
|
594
|
+
pattern.push(
|
|
595
|
+
this.resolvers.module.resolve(
|
|
596
|
+
"./runtime/components/Blocks/FromLibrary/*.vue"
|
|
597
|
+
)
|
|
598
|
+
);
|
|
599
|
+
pattern.push(
|
|
600
|
+
this.resolvers.module.resolve(
|
|
601
|
+
"./runtime/components/Blocks/Fragment/*.vue"
|
|
602
|
+
)
|
|
629
603
|
);
|
|
604
|
+
const fieldListTypes = providedOptions.fieldListTypes || [];
|
|
605
|
+
if (!fieldListTypes.includes("default")) {
|
|
606
|
+
fieldListTypes.push("default");
|
|
607
|
+
}
|
|
608
|
+
const chunkNames = providedOptions.chunkNames || [];
|
|
609
|
+
if (!chunkNames.includes("global")) {
|
|
610
|
+
chunkNames.push("global");
|
|
611
|
+
}
|
|
612
|
+
this.options = {
|
|
613
|
+
...providedOptions,
|
|
614
|
+
pattern,
|
|
615
|
+
fieldListTypes: fieldListTypes.filter(onlyUnique),
|
|
616
|
+
chunkNames: chunkNames.filter(onlyUnique)
|
|
617
|
+
};
|
|
630
618
|
}
|
|
619
|
+
relativePaths;
|
|
620
|
+
paths;
|
|
621
|
+
resolvers;
|
|
622
|
+
fileCache;
|
|
623
|
+
options;
|
|
624
|
+
isDev;
|
|
625
|
+
isModuleBuild;
|
|
631
626
|
/**
|
|
632
|
-
*
|
|
627
|
+
* Transform the path relative to the module's build directory.
|
|
628
|
+
*
|
|
629
|
+
* @param path - The absolute path.
|
|
630
|
+
*
|
|
631
|
+
* @returns The path relative to the module's build directory.
|
|
633
632
|
*/
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
return `${chunkName}: () => import('./chunk-${chunkName}')`;
|
|
637
|
-
});
|
|
638
|
-
const nonGlobalChunkMapping = Object.values(this.definitions).reduce((acc, v) => {
|
|
639
|
-
if (v && v.chunkName !== "global") {
|
|
640
|
-
acc["block_" + v.definition.bundle] = v.chunkName;
|
|
641
|
-
}
|
|
642
|
-
return acc;
|
|
643
|
-
}, {});
|
|
644
|
-
const nonGlobalFragmentChunkMapping = Object.values(
|
|
645
|
-
this.fragmentDefinitions
|
|
646
|
-
).reduce((acc, v) => {
|
|
647
|
-
if (v && v.chunkName !== "global") {
|
|
648
|
-
acc["fragment_" + v.definition.name] = v.chunkName;
|
|
649
|
-
}
|
|
650
|
-
return acc;
|
|
651
|
-
}, {});
|
|
652
|
-
return `
|
|
653
|
-
import { defineAsyncComponent } from '#imports'
|
|
654
|
-
${this.generateChunkGroup("global", "global", this.definitions)}
|
|
655
|
-
${this.generateChunkGroup(
|
|
656
|
-
"global",
|
|
657
|
-
"globalFragments",
|
|
658
|
-
this.fragmentDefinitions
|
|
659
|
-
)}
|
|
660
|
-
|
|
661
|
-
const chunks: Record<string, () => Promise<any>> = {
|
|
662
|
-
${chunkImports.join(",\n ")}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
const chunkMapping: Record<string, string> = ${JSON.stringify(
|
|
666
|
-
nonGlobalChunkMapping,
|
|
667
|
-
null,
|
|
668
|
-
2
|
|
669
|
-
)}
|
|
670
|
-
|
|
671
|
-
const fragmentChunkMapping: Record<string, string> = ${JSON.stringify(
|
|
672
|
-
nonGlobalFragmentChunkMapping,
|
|
673
|
-
null,
|
|
674
|
-
2
|
|
675
|
-
)}
|
|
676
|
-
|
|
677
|
-
function componentOrFunction(component: any) {
|
|
678
|
-
if (typeof component === 'object') {
|
|
679
|
-
return component
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
return defineAsyncComponent(() => component())
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
export function getBlokkliItemComponent(bundle: string, fieldListType?: string, parentBundle?: string): any {
|
|
686
|
-
const forFieldListType = 'block_' + bundle + '__field_list_type_' + fieldListType
|
|
687
|
-
if (global[forFieldListType]) {
|
|
688
|
-
return componentOrFunction(global[forFieldListType])
|
|
633
|
+
toModuleBuildRelative(path) {
|
|
634
|
+
return relative(this.paths.blokkliBuildDir, path);
|
|
689
635
|
}
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
if (
|
|
693
|
-
return
|
|
636
|
+
findEditAdapterPath() {
|
|
637
|
+
const filePath = this.resolvers.app.resolve("blokkli.editAdapter.ts");
|
|
638
|
+
if (this.fileCache.fileExists(filePath)) {
|
|
639
|
+
return filePath;
|
|
640
|
+
}
|
|
641
|
+
if (this.options.editAdapterPath && this.fileCache.fileExists(this.options.editAdapterPath)) {
|
|
642
|
+
return this.options.editAdapterPath;
|
|
694
643
|
}
|
|
644
|
+
throw new Error(`Missing bl\xF6kkli edit adapter at "${filePath}"`);
|
|
695
645
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
return componentOrFunction(global[key])
|
|
646
|
+
getChunkNames() {
|
|
647
|
+
return this.options.chunkNames || ["global"];
|
|
699
648
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
649
|
+
addComponent(name) {
|
|
650
|
+
addComponent({
|
|
651
|
+
filePath: this.resolvers.module.resolve("./runtime/components/" + name),
|
|
652
|
+
name,
|
|
653
|
+
global: true
|
|
654
|
+
});
|
|
705
655
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
return componentOrFunction(globalFragments[key])
|
|
656
|
+
addComposable(name) {
|
|
657
|
+
addImports({
|
|
658
|
+
name,
|
|
659
|
+
from: this.resolvers.module.resolve("./runtime/composables/" + name)
|
|
660
|
+
});
|
|
712
661
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
}
|
|
662
|
+
addAlias(name, path) {
|
|
663
|
+
this.nuxt.options.alias[name] = path;
|
|
664
|
+
this.nuxt.options.nitro.typescript ||= {};
|
|
665
|
+
this.nuxt.options.nitro.typescript.tsConfig ||= {};
|
|
666
|
+
this.nuxt.options.nitro.typescript.tsConfig.compilerOptions ||= {};
|
|
667
|
+
this.nuxt.options.nitro.typescript.tsConfig.compilerOptions.paths ||= {};
|
|
668
|
+
this.nuxt.options.nitro.typescript.tsConfig.compilerOptions.paths[name] = [
|
|
669
|
+
path
|
|
670
|
+
];
|
|
671
|
+
this.nuxt.options.nitro.typescript.tsConfig.compilerOptions.paths[name + "/*"] = [path + "/*"];
|
|
672
|
+
this.nuxt.options.typescript.tsConfig ||= {};
|
|
673
|
+
this.nuxt.options.typescript.tsConfig.compilerOptions ||= {};
|
|
674
|
+
this.nuxt.options.typescript.tsConfig.compilerOptions.paths ||= {};
|
|
675
|
+
this.nuxt.options.typescript.tsConfig.compilerOptions.paths[name] = [path];
|
|
676
|
+
this.nuxt.options.typescript.tsConfig.compilerOptions.paths[name + "/*"] = [
|
|
677
|
+
path + "/*"
|
|
678
|
+
];
|
|
718
679
|
}
|
|
719
680
|
}
|
|
720
|
-
|
|
681
|
+
|
|
682
|
+
const WRITE = false;
|
|
683
|
+
class ModuleContext {
|
|
684
|
+
constructor(helper, icons, features, blocks, theme) {
|
|
685
|
+
this.helper = helper;
|
|
686
|
+
this.icons = icons;
|
|
687
|
+
this.features = features;
|
|
688
|
+
this.blocks = blocks;
|
|
689
|
+
this.theme = theme;
|
|
721
690
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
691
|
+
templates = [];
|
|
692
|
+
templateContents = /* @__PURE__ */ new Map();
|
|
693
|
+
getTemplateContents(type, name) {
|
|
694
|
+
const contents = this.templateContents.get(type + name);
|
|
695
|
+
if (contents === void 0) {
|
|
696
|
+
throw new Error(
|
|
697
|
+
`Failed to get contents for template "${name}" of type ${type}`
|
|
698
|
+
);
|
|
725
699
|
}
|
|
726
|
-
return
|
|
700
|
+
return contents;
|
|
727
701
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
702
|
+
setTemplateContents(type, name, contents) {
|
|
703
|
+
this.templateContents.set(type + name, contents.trim());
|
|
704
|
+
}
|
|
705
|
+
async generateTemplates(dependencies) {
|
|
706
|
+
for (const template of this.templates) {
|
|
707
|
+
if (dependencies?.length) {
|
|
708
|
+
const shouldUpdate = dependencies.some(
|
|
709
|
+
(v) => template.options.dependencies.includes(v)
|
|
710
|
+
);
|
|
711
|
+
if (!shouldUpdate) {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (template.type === "code") {
|
|
716
|
+
this.setTemplateContents(
|
|
717
|
+
"code",
|
|
718
|
+
template.name,
|
|
719
|
+
await template.buildCode(this)
|
|
720
|
+
);
|
|
721
|
+
this.setTemplateContents(
|
|
722
|
+
"types",
|
|
723
|
+
template.name,
|
|
724
|
+
await template.buildTypes(this)
|
|
725
|
+
);
|
|
738
726
|
} else {
|
|
739
|
-
|
|
727
|
+
this.setTemplateContents(
|
|
728
|
+
"file",
|
|
729
|
+
template.fileName,
|
|
730
|
+
await template.build(this)
|
|
731
|
+
);
|
|
740
732
|
}
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
addTemplate(template) {
|
|
736
|
+
this.templates.push(template);
|
|
737
|
+
if (template.type === "code") {
|
|
738
|
+
addTemplate({
|
|
739
|
+
filename: `blokkli/${template.name}.js`,
|
|
740
|
+
write: template.options.write || WRITE,
|
|
741
|
+
getContents: () => this.getTemplateContents("code", template.name)
|
|
742
|
+
});
|
|
743
|
+
addTypeTemplate({
|
|
744
|
+
filename: `blokkli/${template.name}.d.ts`,
|
|
745
|
+
write: true,
|
|
746
|
+
// Type files are always written.
|
|
747
|
+
getContents: () => {
|
|
748
|
+
const lines = this.getTemplateContents("types", template.name).trim().split("\n");
|
|
749
|
+
const imports = [];
|
|
750
|
+
const declarations = [];
|
|
751
|
+
for (const line of lines) {
|
|
752
|
+
if (line.startsWith("import ") && line.includes(" from ")) {
|
|
753
|
+
imports.push(line);
|
|
754
|
+
} else {
|
|
755
|
+
declarations.push(line);
|
|
763
756
|
}
|
|
764
|
-
}
|
|
757
|
+
}
|
|
758
|
+
return `${imports.join("\n")}
|
|
759
|
+
|
|
760
|
+
declare module '#blokkli-build/${template.name}' {
|
|
761
|
+
${declarations.join("\n ")}
|
|
762
|
+
}`;
|
|
765
763
|
}
|
|
764
|
+
});
|
|
765
|
+
} else {
|
|
766
|
+
const filename = template.fileName.startsWith("/") ? template.fileName : `blokkli/${template.fileName}`;
|
|
767
|
+
if (filename.endsWith(".d.ts")) {
|
|
768
|
+
addTypeTemplate({
|
|
769
|
+
filename,
|
|
770
|
+
write: true,
|
|
771
|
+
getContents: () => this.getTemplateContents("file", template.fileName)
|
|
772
|
+
});
|
|
766
773
|
} else {
|
|
767
|
-
|
|
774
|
+
addTemplate({
|
|
775
|
+
filename,
|
|
776
|
+
write: true,
|
|
777
|
+
getContents: () => this.getTemplateContents("file", template.fileName)
|
|
778
|
+
});
|
|
768
779
|
}
|
|
769
|
-
return acc;
|
|
770
|
-
}, []);
|
|
771
|
-
let content = `
|
|
772
|
-
${imports.join("\n")}
|
|
773
|
-
|
|
774
|
-
const ${exportName}: Record<string, any> = {
|
|
775
|
-
${map.join(",\n ")}
|
|
776
|
-
}
|
|
777
|
-
`;
|
|
778
|
-
if (addExport) {
|
|
779
|
-
content += `export default ${exportName}`;
|
|
780
780
|
}
|
|
781
|
-
return content;
|
|
782
781
|
}
|
|
783
782
|
}
|
|
784
783
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
* Add files by path.
|
|
795
|
-
*/
|
|
796
|
-
addFiles(files) {
|
|
797
|
-
return Promise.all(files.map((v) => this.handleFile(v)));
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
* Read the file and extract the blokkli component definitions.
|
|
801
|
-
*
|
|
802
|
-
* Returns a promise containing a boolean that indicated if the given file
|
|
803
|
-
* should trigger a rebuild of the query.
|
|
804
|
-
*/
|
|
805
|
-
async handleFile(filePath2) {
|
|
806
|
-
const fileSource = await this.readFile(filePath2);
|
|
807
|
-
const extracted = this.extractSingle(fileSource, filePath2);
|
|
808
|
-
if (!extracted) {
|
|
809
|
-
if (this.definitions[filePath2]) {
|
|
810
|
-
this.definitions[filePath2] = void 0;
|
|
811
|
-
return true;
|
|
812
|
-
}
|
|
813
|
-
return false;
|
|
814
|
-
}
|
|
815
|
-
const { definition: definition2, source: source2 } = extracted;
|
|
816
|
-
if (!this.definitions[filePath2]) {
|
|
817
|
-
const regex = /\/Features\/([^/]+)\//;
|
|
818
|
-
const componentName = filePath2.match(regex)?.[1] || "";
|
|
819
|
-
this.definitions[filePath2] = {
|
|
820
|
-
id: definition2.id,
|
|
821
|
-
componentName,
|
|
822
|
-
componentPath: filePath2,
|
|
823
|
-
filePath: filePath2,
|
|
824
|
-
definition: definition2,
|
|
825
|
-
source: source2
|
|
826
|
-
};
|
|
827
|
-
return true;
|
|
784
|
+
function defineCodeTemplate(name, buildCode, buildTypes, options) {
|
|
785
|
+
return {
|
|
786
|
+
type: "code",
|
|
787
|
+
name,
|
|
788
|
+
buildCode,
|
|
789
|
+
buildTypes,
|
|
790
|
+
options: {
|
|
791
|
+
dependencies: options?.dependencies || [],
|
|
792
|
+
write: !!options?.write
|
|
828
793
|
}
|
|
829
|
-
|
|
830
|
-
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function defineFileTemplate(fileName, build) {
|
|
797
|
+
return {
|
|
798
|
+
type: "file",
|
|
799
|
+
fileName,
|
|
800
|
+
build,
|
|
801
|
+
options: {
|
|
802
|
+
dependencies: [],
|
|
803
|
+
write: true
|
|
831
804
|
}
|
|
832
|
-
|
|
833
|
-
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function withHelper(cb) {
|
|
808
|
+
return cb;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
function toObject(name, map, noExport) {
|
|
812
|
+
const lines = [...map.entries()].map(([key, value]) => {
|
|
813
|
+
return `'${key}': ${value}`;
|
|
814
|
+
}).sort().join(",\n ");
|
|
815
|
+
if (noExport) {
|
|
816
|
+
return `
|
|
817
|
+
const ${name} = {
|
|
818
|
+
${lines}
|
|
819
|
+
}
|
|
820
|
+
`;
|
|
834
821
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
822
|
+
return `
|
|
823
|
+
export const ${name} = {
|
|
824
|
+
${lines}
|
|
825
|
+
}
|
|
826
|
+
`;
|
|
827
|
+
}
|
|
828
|
+
function toImports(map) {
|
|
829
|
+
return [...map.entries()].map(([key, path]) => {
|
|
830
|
+
return `import ${key} from '${path}'`;
|
|
831
|
+
}).sort().join("\n");
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
const icons = defineCodeTemplate(
|
|
835
|
+
"icons",
|
|
836
|
+
(ctx) => {
|
|
837
|
+
const imports = /* @__PURE__ */ new Map();
|
|
838
|
+
const icons = /* @__PURE__ */ new Map();
|
|
839
|
+
const files = ctx.icons.files.values();
|
|
840
|
+
for (const file of files) {
|
|
841
|
+
const name = basename(file.filePath, ".svg").toLowerCase();
|
|
842
|
+
const importName = "icon_" + toValidVariableName(name);
|
|
843
|
+
imports.set(importName, `${file.filePath}?raw`);
|
|
844
|
+
icons.set(name, importName);
|
|
852
845
|
}
|
|
846
|
+
return `${toImports(imports)}
|
|
847
|
+
|
|
848
|
+
${toObject("icons", icons)}
|
|
849
|
+
`;
|
|
850
|
+
},
|
|
851
|
+
(ctx) => {
|
|
852
|
+
const allIconNames = [...ctx.icons.files.values()].map((file) => {
|
|
853
|
+
return basename(file.filePath, ".svg").toLowerCase();
|
|
854
|
+
}).sort().map((name) => `"${name}"`).join("\n | ");
|
|
855
|
+
return `
|
|
856
|
+
export type BlokkliIcon =
|
|
857
|
+
| ${allIconNames}
|
|
858
|
+
export const icons: Record<BlokkliIcon, string>
|
|
859
|
+
`;
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
dependencies: ["icons"]
|
|
853
863
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
+
);
|
|
865
|
+
|
|
866
|
+
const features = defineCodeTemplate(
|
|
867
|
+
"features",
|
|
868
|
+
(ctx) => {
|
|
869
|
+
const features = ctx.features.getEnabledFeatures().sort((a, b) => b.id.localeCompare(a.id));
|
|
870
|
+
const featuresComponents = /* @__PURE__ */ new Map();
|
|
871
|
+
const definitions = [];
|
|
872
|
+
const declarations = [];
|
|
873
|
+
const imports = /* @__PURE__ */ new Map();
|
|
874
|
+
for (const feature of features) {
|
|
875
|
+
const componentVarName = toValidVariableName(`component_${feature.id}`);
|
|
876
|
+
const declarationVarName = toValidVariableName(`feature_${feature.id}`);
|
|
877
|
+
declarations.push(
|
|
878
|
+
`const ${declarationVarName} = ${feature.definitionSource}`
|
|
879
|
+
);
|
|
880
|
+
definitions.push(declarationVarName);
|
|
881
|
+
imports.set(componentVarName, feature.componentPath);
|
|
882
|
+
featuresComponents.set(feature.id, componentVarName);
|
|
883
|
+
}
|
|
884
|
+
const availableFeaturesAtBuild = features.map((v) => v.id);
|
|
885
|
+
return `${toImports(imports)}
|
|
886
|
+
|
|
887
|
+
export const availableFeaturesAtBuild = ${JSON.stringify(
|
|
888
|
+
availableFeaturesAtBuild.sort()
|
|
889
|
+
)}
|
|
890
|
+
|
|
891
|
+
${toObject("featureComponents", featuresComponents)}
|
|
892
|
+
|
|
893
|
+
${declarations.join("\n\n")}
|
|
894
|
+
|
|
895
|
+
export const featureDefinitions = [
|
|
896
|
+
${definitions.join(",\n ")}
|
|
897
|
+
]
|
|
898
|
+
`;
|
|
899
|
+
},
|
|
900
|
+
(ctx) => {
|
|
901
|
+
const features = ctx.features.getEnabledFeatures().map((v) => v.id);
|
|
902
|
+
const availableFeaturesAtBuild = features;
|
|
903
|
+
return `
|
|
904
|
+
import type { BlokkliAdapter } from '${ctx.helper.relativePaths.ADAPTER}'
|
|
905
|
+
import type { Viewport } from '${ctx.helper.relativePaths.CONSTANTS}'
|
|
906
|
+
import type { Component } from 'vue'
|
|
907
|
+
|
|
908
|
+
type AdapterMethods = keyof BlokkliAdapter<any>
|
|
909
|
+
|
|
910
|
+
export type ValidFeatureKey = ${availableFeaturesAtBuild.map((v) => '"' + v + '"').join(" | ")}
|
|
911
|
+
|
|
912
|
+
export declare const featureComponents: Record<ValidFeatureKey, Component>
|
|
913
|
+
export declare const featureDefinitions: FeatureDefinition[]
|
|
914
|
+
export declare const availableFeaturesAtBuild: ValidFeatureKey[]
|
|
915
|
+
`;
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
dependencies: ["features"]
|
|
864
919
|
}
|
|
865
|
-
|
|
920
|
+
);
|
|
921
|
+
|
|
922
|
+
const featuresJson = defineFileTemplate("features-data.json", async (ctx) => {
|
|
923
|
+
const features = [...ctx.features.files.values()];
|
|
924
|
+
const featuresData = await Promise.all(
|
|
925
|
+
features.map(async (v) => {
|
|
926
|
+
const docsPath = v.filePath.replace("index.vue", "docs.md");
|
|
927
|
+
let docs = "";
|
|
928
|
+
if (ctx.helper.fileCache.fileExists(docsPath)) {
|
|
929
|
+
docs = await ctx.helper.fileCache.read(docsPath);
|
|
930
|
+
}
|
|
931
|
+
return {
|
|
932
|
+
...v,
|
|
933
|
+
repoRelativePath: v.filePath.replace(/.*\/src/, "/src"),
|
|
934
|
+
docs
|
|
935
|
+
};
|
|
936
|
+
})
|
|
937
|
+
);
|
|
938
|
+
return JSON.stringify(featuresData, null, 2);
|
|
939
|
+
});
|
|
866
940
|
|
|
867
941
|
const addCommentToItem$2 = {
|
|
868
942
|
source: "Comment",
|
|
@@ -6222,12 +6296,66 @@ const it = {
|
|
|
6222
6296
|
validationsTourText: validationsTourText
|
|
6223
6297
|
};
|
|
6224
6298
|
|
|
6225
|
-
const translations = {
|
|
6299
|
+
const translations$1 = {
|
|
6226
6300
|
de,
|
|
6227
6301
|
fr,
|
|
6228
6302
|
it
|
|
6229
6303
|
};
|
|
6230
6304
|
|
|
6305
|
+
const translations = defineCodeTemplate(
|
|
6306
|
+
"translations",
|
|
6307
|
+
(ctx) => {
|
|
6308
|
+
const translations = {};
|
|
6309
|
+
Object.keys(translations$1).forEach((language) => {
|
|
6310
|
+
translations[language] = {};
|
|
6311
|
+
Object.keys(translations$1[language]).forEach((key) => {
|
|
6312
|
+
translations[language][key] = translations$1[language][key].translation;
|
|
6313
|
+
});
|
|
6314
|
+
});
|
|
6315
|
+
const merged = defu(ctx.helper.options.translations, translations);
|
|
6316
|
+
return `export const translations = ${JSON.stringify(merged, null, 2)}`;
|
|
6317
|
+
},
|
|
6318
|
+
() => {
|
|
6319
|
+
return `
|
|
6320
|
+
export declare const translations: Record<string, Record<string, string>>
|
|
6321
|
+
`;
|
|
6322
|
+
}
|
|
6323
|
+
);
|
|
6324
|
+
|
|
6325
|
+
const editAdapter = defineCodeTemplate(
|
|
6326
|
+
"edit-adapter",
|
|
6327
|
+
(ctx) => {
|
|
6328
|
+
const pathRelative = ctx.helper.toModuleBuildRelative(
|
|
6329
|
+
ctx.helper.paths.editAdapter
|
|
6330
|
+
);
|
|
6331
|
+
return `
|
|
6332
|
+
import adapter from '${pathRelative}'
|
|
6333
|
+
|
|
6334
|
+
export default adapter
|
|
6335
|
+
`;
|
|
6336
|
+
},
|
|
6337
|
+
(ctx) => {
|
|
6338
|
+
return `
|
|
6339
|
+
import type { BlokkliAdapterFactory } from '${ctx.helper.relativePaths.ADAPTER}'
|
|
6340
|
+
|
|
6341
|
+
declare const adapter: BlokkliAdapterFactory<any>
|
|
6342
|
+
|
|
6343
|
+
export default adapter
|
|
6344
|
+
`;
|
|
6345
|
+
}
|
|
6346
|
+
);
|
|
6347
|
+
|
|
6348
|
+
const styles = defineFileTemplate("styles.css", (ctx) => {
|
|
6349
|
+
const cssFilePath = ctx.helper.resolvers.module.resolve(
|
|
6350
|
+
"./runtime/css/output.css"
|
|
6351
|
+
);
|
|
6352
|
+
return `
|
|
6353
|
+
@import url("${relative(ctx.helper.paths.blokkliBuildDir, cssFilePath)}");
|
|
6354
|
+
|
|
6355
|
+
${ctx.theme.css}
|
|
6356
|
+
`;
|
|
6357
|
+
});
|
|
6358
|
+
|
|
6231
6359
|
const accent$3 = {
|
|
6232
6360
|
"50": [
|
|
6233
6361
|
237,
|
|
@@ -6992,27 +7120,871 @@ const nuxt = {
|
|
|
6992
7120
|
lime: lime
|
|
6993
7121
|
};
|
|
6994
7122
|
|
|
6995
|
-
const themes = {
|
|
6996
|
-
fire,
|
|
6997
|
-
arctic,
|
|
6998
|
-
gruvbox,
|
|
6999
|
-
nuxt
|
|
7000
|
-
};
|
|
7001
|
-
const getTheme = (v) => {
|
|
7002
|
-
if (typeof v === "string") {
|
|
7003
|
-
if (v === "arctic") {
|
|
7004
|
-
return themes.arctic;
|
|
7005
|
-
} else if (v === "gruvbox") {
|
|
7006
|
-
return themes.gruvbox;
|
|
7007
|
-
} else if (v === "fire") {
|
|
7008
|
-
return themes.fire;
|
|
7009
|
-
} else if (v === "nuxt") {
|
|
7010
|
-
return themes.nuxt;
|
|
7123
|
+
const themes = {
|
|
7124
|
+
fire,
|
|
7125
|
+
arctic,
|
|
7126
|
+
gruvbox,
|
|
7127
|
+
nuxt
|
|
7128
|
+
};
|
|
7129
|
+
const getTheme = (v) => {
|
|
7130
|
+
if (typeof v === "string") {
|
|
7131
|
+
if (v === "arctic") {
|
|
7132
|
+
return themes.arctic;
|
|
7133
|
+
} else if (v === "gruvbox") {
|
|
7134
|
+
return themes.gruvbox;
|
|
7135
|
+
} else if (v === "fire") {
|
|
7136
|
+
return themes.fire;
|
|
7137
|
+
} else if (v === "nuxt") {
|
|
7138
|
+
return themes.nuxt;
|
|
7139
|
+
}
|
|
7140
|
+
throw new Error(`Invalid theme name: ${v}`);
|
|
7141
|
+
}
|
|
7142
|
+
return v || {};
|
|
7143
|
+
};
|
|
7144
|
+
|
|
7145
|
+
const config = defineCodeTemplate(
|
|
7146
|
+
"config",
|
|
7147
|
+
(ctx) => {
|
|
7148
|
+
const settingsOverride = ctx.helper.options.settingsOverride || {};
|
|
7149
|
+
return `
|
|
7150
|
+
export const hasCustomTheme = ${JSON.stringify(ctx.theme.hasCustomTheme)}
|
|
7151
|
+
|
|
7152
|
+
export const themes = ${JSON.stringify(themes, null, 2)}
|
|
7153
|
+
|
|
7154
|
+
export const theme = ${JSON.stringify(ctx.theme.fullTheme, null, 2)}
|
|
7155
|
+
|
|
7156
|
+
export const settingsOverride = ${JSON.stringify(settingsOverride)}
|
|
7157
|
+
|
|
7158
|
+
export const blokkliVersion = ${JSON.stringify(version)}
|
|
7159
|
+
|
|
7160
|
+
export const storageDefaults = ${JSON.stringify(
|
|
7161
|
+
ctx.helper.options.storageDefaults || {}
|
|
7162
|
+
)}
|
|
7163
|
+
export const defaultLanguage = ${JSON.stringify(
|
|
7164
|
+
ctx.helper.options.defaultLanguage || "en"
|
|
7165
|
+
)}
|
|
7166
|
+
export const forceDefaultLanguage = ${JSON.stringify(
|
|
7167
|
+
!!ctx.helper.options.forceDefaultLanguage
|
|
7168
|
+
)}
|
|
7169
|
+
`;
|
|
7170
|
+
},
|
|
7171
|
+
(ctx) => {
|
|
7172
|
+
return `
|
|
7173
|
+
import type { Theme } from '${ctx.helper.relativePaths.TYPES_THEME}'
|
|
7174
|
+
import type { ModuleOptionsSettings } from '#blokkli-build/module-types'
|
|
7175
|
+
|
|
7176
|
+
/**
|
|
7177
|
+
* Whether the app uses a custom theme.
|
|
7178
|
+
*/
|
|
7179
|
+
export declare const hasCustomTheme: boolean
|
|
7180
|
+
|
|
7181
|
+
/**
|
|
7182
|
+
* All available themes.
|
|
7183
|
+
*/
|
|
7184
|
+
export declare const themes: Record<string, Theme>
|
|
7185
|
+
|
|
7186
|
+
/**
|
|
7187
|
+
* The default theme.
|
|
7188
|
+
*/
|
|
7189
|
+
export declare const theme: Theme
|
|
7190
|
+
|
|
7191
|
+
/**
|
|
7192
|
+
* Overrides for settings.
|
|
7193
|
+
*/
|
|
7194
|
+
export declare const settingsOverride: ModuleOptionsSettings
|
|
7195
|
+
|
|
7196
|
+
/**
|
|
7197
|
+
* The version of the @blokkli/editor package.
|
|
7198
|
+
*/
|
|
7199
|
+
export declare const blokkliVersion: string
|
|
7200
|
+
|
|
7201
|
+
/**
|
|
7202
|
+
* Default storage settings.
|
|
7203
|
+
*/
|
|
7204
|
+
export declare const storageDefaults: Record<string, string|boolean|string[]>
|
|
7205
|
+
|
|
7206
|
+
/**
|
|
7207
|
+
* The default/fallback language.
|
|
7208
|
+
*/
|
|
7209
|
+
export declare const defaultLanguage: string
|
|
7210
|
+
|
|
7211
|
+
/**
|
|
7212
|
+
* Whether to always force the default language, even on translation pages.
|
|
7213
|
+
*/
|
|
7214
|
+
export declare const forceDefaultLanguage: boolean
|
|
7215
|
+
`;
|
|
7216
|
+
}
|
|
7217
|
+
);
|
|
7218
|
+
|
|
7219
|
+
const definitions = defineCodeTemplate(
|
|
7220
|
+
"definitions",
|
|
7221
|
+
(ctx) => {
|
|
7222
|
+
const blocks = [];
|
|
7223
|
+
const fragments = [];
|
|
7224
|
+
const icons = /* @__PURE__ */ new Map();
|
|
7225
|
+
const definitions = [];
|
|
7226
|
+
const files = [...ctx.blocks.files.values()].sort(
|
|
7227
|
+
(a, b) => b.identifier.localeCompare(a.identifier)
|
|
7228
|
+
);
|
|
7229
|
+
let key = "";
|
|
7230
|
+
files.forEach((file) => {
|
|
7231
|
+
if (!file.definition || !file.definitionSource) {
|
|
7232
|
+
return;
|
|
7233
|
+
}
|
|
7234
|
+
const identifier = file.identifier;
|
|
7235
|
+
key += identifier;
|
|
7236
|
+
if (isBlock(file.definition)) {
|
|
7237
|
+
definitions.push(`const ${identifier} = ${file.definitionSource}`);
|
|
7238
|
+
blocks.push(identifier);
|
|
7239
|
+
if (file.iconContents) {
|
|
7240
|
+
icons.set(file.definition.bundle, JSON.stringify(file.iconContents));
|
|
7241
|
+
}
|
|
7242
|
+
} else {
|
|
7243
|
+
definitions.push(`const ${identifier} = ${file.definitionSource}`);
|
|
7244
|
+
fragments.push(identifier);
|
|
7245
|
+
}
|
|
7246
|
+
});
|
|
7247
|
+
const renderKey = hash(key);
|
|
7248
|
+
return `
|
|
7249
|
+
${definitions.join("\n\n")}
|
|
7250
|
+
|
|
7251
|
+
const blocks = [
|
|
7252
|
+
${blocks.join(",\n ")}
|
|
7253
|
+
]
|
|
7254
|
+
|
|
7255
|
+
const fragments = [
|
|
7256
|
+
${fragments.join(",\n ")}
|
|
7257
|
+
]
|
|
7258
|
+
|
|
7259
|
+
${toObject("icons", icons, true)}
|
|
7260
|
+
|
|
7261
|
+
|
|
7262
|
+
const globalOptions = ${JSON.stringify(ctx.helper.options.globalOptions || {})}
|
|
7263
|
+
|
|
7264
|
+
const renderKey = "${renderKey}"
|
|
7265
|
+
|
|
7266
|
+
const definitions = {
|
|
7267
|
+
blocks,
|
|
7268
|
+
fragments,
|
|
7269
|
+
icons,
|
|
7270
|
+
globalOptions,
|
|
7271
|
+
renderKey
|
|
7272
|
+
}
|
|
7273
|
+
|
|
7274
|
+
export default definitions
|
|
7275
|
+
`;
|
|
7276
|
+
},
|
|
7277
|
+
(ctx) => {
|
|
7278
|
+
const fragmentNames = [];
|
|
7279
|
+
for (const file of ctx.blocks.files.values()) {
|
|
7280
|
+
if (!file.definition) {
|
|
7281
|
+
continue;
|
|
7282
|
+
}
|
|
7283
|
+
if (isBlock(file.definition)) {
|
|
7284
|
+
continue;
|
|
7285
|
+
}
|
|
7286
|
+
fragmentNames.push(`'${file.definition.name}'`);
|
|
7287
|
+
}
|
|
7288
|
+
return `
|
|
7289
|
+
import type { GlobalOptionsKey, ValidFieldListTypes, BlockBundleWithNested, ValidGlobalConfigKeys } from '#blokkli-build/generated-types'
|
|
7290
|
+
import type { BlockDefinitionInput, BlockDefinitionOptionsInput, FragmentDefinitionInput } from '${ctx.helper.relativePaths.TYPES}'
|
|
7291
|
+
|
|
7292
|
+
export type BlockDefinition = BlockDefinitionInput<BlockDefinitionOptionsInput, GlobalOptionsKey[]>
|
|
7293
|
+
export type FragmentDefinition = FragmentDefinitionInput<Record<string, any>, GlobalOptionsKey[]>
|
|
7294
|
+
|
|
7295
|
+
export type BlokkliFragmentName = ${fragmentNames.join(" | ") || "never"}
|
|
7296
|
+
|
|
7297
|
+
const globalOptions = ${JSON.stringify(ctx.helper.options.globalOptions || {})} as const
|
|
7298
|
+
|
|
7299
|
+
export type GlobalOptionsType = typeof globalOptions
|
|
7300
|
+
|
|
7301
|
+
export type Definitions = {
|
|
7302
|
+
blocks: BlockDefinition[]
|
|
7303
|
+
fragments: FragmentDefinition[]
|
|
7304
|
+
icons: Record<string, string>
|
|
7305
|
+
globalOptions: BlockDefinitionOptionsInput
|
|
7306
|
+
renderKey: string
|
|
7307
|
+
}
|
|
7308
|
+
|
|
7309
|
+
const definitions: Definitions
|
|
7310
|
+
|
|
7311
|
+
export default definitions
|
|
7312
|
+
`;
|
|
7313
|
+
},
|
|
7314
|
+
{
|
|
7315
|
+
dependencies: ["block-content", "block-path"]
|
|
7316
|
+
}
|
|
7317
|
+
);
|
|
7318
|
+
|
|
7319
|
+
const moduleTypes = defineCodeTemplate(
|
|
7320
|
+
"module-types",
|
|
7321
|
+
() => {
|
|
7322
|
+
return `export {}`;
|
|
7323
|
+
},
|
|
7324
|
+
(ctx) => {
|
|
7325
|
+
const features = ctx.features.getEnabledFeatures();
|
|
7326
|
+
const settings = [];
|
|
7327
|
+
features.forEach((feature) => {
|
|
7328
|
+
if (feature.definition.settings) {
|
|
7329
|
+
Object.entries(feature.definition.settings).sort((a, b) => a[0].localeCompare(b[0])).forEach(([key, setting]) => {
|
|
7330
|
+
const settingsKey = `feature:${feature.id}:${key}`;
|
|
7331
|
+
settings.push(`/** ${setting.label} */`);
|
|
7332
|
+
if (setting.type === "radios") {
|
|
7333
|
+
const type = Object.keys(setting.options).map((v) => `'${v}'`).join(" | ");
|
|
7334
|
+
settings.push(
|
|
7335
|
+
`'${settingsKey}'?: { disable?: boolean, default?: ${type} }
|
|
7336
|
+
`
|
|
7337
|
+
);
|
|
7338
|
+
} else if (setting.type === "checkbox") {
|
|
7339
|
+
settings.push(
|
|
7340
|
+
`'${settingsKey}'?: { disable?: boolean, default?: boolean }
|
|
7341
|
+
`
|
|
7342
|
+
);
|
|
7343
|
+
} else if (setting.type === "slider") {
|
|
7344
|
+
settings.push(
|
|
7345
|
+
`'${settingsKey}'?: { disable?: boolean, default?: number }
|
|
7346
|
+
`
|
|
7347
|
+
);
|
|
7348
|
+
} else {
|
|
7349
|
+
settings.push(`'${settingsKey}'?: { disable?: boolean }
|
|
7350
|
+
`);
|
|
7351
|
+
}
|
|
7352
|
+
});
|
|
7353
|
+
}
|
|
7354
|
+
});
|
|
7355
|
+
return `
|
|
7356
|
+
export type ModuleOptionsSettings = {
|
|
7357
|
+
${settings.join("\n ")}
|
|
7358
|
+
}
|
|
7359
|
+
`;
|
|
7360
|
+
},
|
|
7361
|
+
{
|
|
7362
|
+
dependencies: ["features"]
|
|
7363
|
+
}
|
|
7364
|
+
);
|
|
7365
|
+
|
|
7366
|
+
const runtimeOptions = defineCodeTemplate(
|
|
7367
|
+
"runtime-options",
|
|
7368
|
+
(ctx) => {
|
|
7369
|
+
const globalOptions = ctx.helper.options.globalOptions || {};
|
|
7370
|
+
const files = [...ctx.blocks.files.values()];
|
|
7371
|
+
const items = files.map((v) => {
|
|
7372
|
+
if (v.definition && v.identifier) {
|
|
7373
|
+
if (isBlock(v.definition)) {
|
|
7374
|
+
return {
|
|
7375
|
+
varName: v.identifier,
|
|
7376
|
+
definition: v.definition,
|
|
7377
|
+
variations: v.variations
|
|
7378
|
+
};
|
|
7379
|
+
}
|
|
7380
|
+
return {
|
|
7381
|
+
varName: v.identifier,
|
|
7382
|
+
definition: v.definition,
|
|
7383
|
+
variations: v.variations
|
|
7384
|
+
};
|
|
7385
|
+
}
|
|
7386
|
+
return null;
|
|
7387
|
+
}).filter(falsy);
|
|
7388
|
+
const declarations = [];
|
|
7389
|
+
const OPTIONS = /* @__PURE__ */ new Map();
|
|
7390
|
+
for (const item of items) {
|
|
7391
|
+
const optionDefinitions = Object.entries(item.definition.options || {});
|
|
7392
|
+
const options = {};
|
|
7393
|
+
if (item.definition.globalOptions) {
|
|
7394
|
+
item.definition.globalOptions.forEach((name) => {
|
|
7395
|
+
const option = globalOptions[name];
|
|
7396
|
+
if (option) {
|
|
7397
|
+
options[name] = [option.type, option.default];
|
|
7398
|
+
}
|
|
7399
|
+
});
|
|
7400
|
+
}
|
|
7401
|
+
optionDefinitions.forEach(([name, option]) => {
|
|
7402
|
+
options[name] = [option.type, option.default];
|
|
7403
|
+
});
|
|
7404
|
+
const hasOptions = Object.keys(options).length > 0;
|
|
7405
|
+
if (hasOptions) {
|
|
7406
|
+
declarations.push(`const ${item.varName} = ${JSON.stringify(options)}`);
|
|
7407
|
+
OPTIONS.set(item.varName, item.varName);
|
|
7408
|
+
}
|
|
7409
|
+
item.variations.forEach((variation) => {
|
|
7410
|
+
if (hasOptions) {
|
|
7411
|
+
OPTIONS.set(variation, item.varName);
|
|
7412
|
+
}
|
|
7413
|
+
});
|
|
7414
|
+
}
|
|
7415
|
+
return `
|
|
7416
|
+
${declarations.join("\n")}
|
|
7417
|
+
|
|
7418
|
+
${toObject("OPTIONS", OPTIONS)}
|
|
7419
|
+
`;
|
|
7420
|
+
},
|
|
7421
|
+
(ctx) => {
|
|
7422
|
+
const globalOptions = ctx.helper.options.globalOptions || {};
|
|
7423
|
+
const blocks = [...ctx.blocks.files.values()].map((v) => {
|
|
7424
|
+
if (v.definition && isBlock(v.definition)) {
|
|
7425
|
+
return v.definition;
|
|
7426
|
+
}
|
|
7427
|
+
return null;
|
|
7428
|
+
}).filter(falsy);
|
|
7429
|
+
function getOptionTypes(definition) {
|
|
7430
|
+
const definedOptions = definition.options || {};
|
|
7431
|
+
const blockGlobalOptions = definition.globalOptions || [];
|
|
7432
|
+
blockGlobalOptions.forEach((key) => {
|
|
7433
|
+
if (globalOptions[key]) {
|
|
7434
|
+
definedOptions[key] = globalOptions[key];
|
|
7435
|
+
}
|
|
7436
|
+
});
|
|
7437
|
+
return Object.entries(definedOptions || {}).map(([key, option]) => {
|
|
7438
|
+
if (option.type === "text" || option.type === "datetime-local") {
|
|
7439
|
+
return `${key}: string`;
|
|
7440
|
+
} else if (option.type === "checkbox") {
|
|
7441
|
+
return `${key}: boolean`;
|
|
7442
|
+
} else if (option.type === "checkboxes") {
|
|
7443
|
+
const possibleValues = Object.keys(option.options).map((v) => `'${v}'`).join(" | ") || "string";
|
|
7444
|
+
return `${key}: Array<${possibleValues}>`;
|
|
7445
|
+
} else if (option.type === "radios") {
|
|
7446
|
+
const possibleValues = Object.keys(option.options).map((v) => `'${v}'`).join(" | ") || "string";
|
|
7447
|
+
return `${key}: ${possibleValues}`;
|
|
7448
|
+
} else if (option.type === "color") {
|
|
7449
|
+
return key + ": `#${string}`";
|
|
7450
|
+
} else if (option.type === "range" || option.type === "number") {
|
|
7451
|
+
return `${key}: number`;
|
|
7452
|
+
}
|
|
7453
|
+
});
|
|
7454
|
+
}
|
|
7455
|
+
const runtimeMappedOptionTypes = blocks.map((definition) => {
|
|
7456
|
+
if (definition.renderFor) {
|
|
7457
|
+
return null;
|
|
7458
|
+
}
|
|
7459
|
+
const bundle = definition.bundle;
|
|
7460
|
+
const options = getOptionTypes(definition).join("\n ");
|
|
7461
|
+
if (!options) {
|
|
7462
|
+
return ` ${bundle}: {}`;
|
|
7463
|
+
}
|
|
7464
|
+
return ` ${bundle}: {
|
|
7465
|
+
${options}
|
|
7466
|
+
}`;
|
|
7467
|
+
}).filter(falsy).join(",\n");
|
|
7468
|
+
return `
|
|
7469
|
+
import type { BlockOptionDefinition } from '${ctx.helper.relativePaths.TYPES_BLOKK_OPTIONS}'
|
|
7470
|
+
|
|
7471
|
+
export type RuntimeBlockOptionArray = {
|
|
7472
|
+
[T in BlockOptionDefinition as T['type']]: [T['type'], T['default']]
|
|
7473
|
+
}[BlockOptionDefinition['type']]
|
|
7474
|
+
|
|
7475
|
+
export type RuntimeBlockOptions = {
|
|
7476
|
+
${runtimeMappedOptionTypes}
|
|
7477
|
+
}
|
|
7478
|
+
|
|
7479
|
+
export declare const OPTIONS: Record<string, Record<string, RuntimeBlockOptionArray>>
|
|
7480
|
+
`;
|
|
7481
|
+
},
|
|
7482
|
+
{
|
|
7483
|
+
dependencies: ["block-content", "block-path"]
|
|
7484
|
+
}
|
|
7485
|
+
);
|
|
7486
|
+
|
|
7487
|
+
const editComponents = defineCodeTemplate(
|
|
7488
|
+
"edit-components",
|
|
7489
|
+
(ctx) => {
|
|
7490
|
+
const imports = {};
|
|
7491
|
+
const proxyComponents = /* @__PURE__ */ new Map();
|
|
7492
|
+
const diffComponents = /* @__PURE__ */ new Map();
|
|
7493
|
+
for (const file of ctx.blocks.files.values()) {
|
|
7494
|
+
if (!file.definition || !isBlock(file.definition)) {
|
|
7495
|
+
continue;
|
|
7496
|
+
}
|
|
7497
|
+
const { bundle } = file.definition;
|
|
7498
|
+
if (file.proxyComponentPath) {
|
|
7499
|
+
const importName = "proxy_" + bundle;
|
|
7500
|
+
imports[importName] = file.proxyComponentPath;
|
|
7501
|
+
proxyComponents.set(bundle, importName);
|
|
7502
|
+
} else if (file.diffComponentPath) {
|
|
7503
|
+
const importName = "diff_" + file.definition.bundle;
|
|
7504
|
+
imports[importName] = file.diffComponentPath;
|
|
7505
|
+
diffComponents.set(bundle, importName);
|
|
7506
|
+
}
|
|
7507
|
+
}
|
|
7508
|
+
const importLines = Object.entries(imports).map(([variableName, path]) => {
|
|
7509
|
+
return `import ${variableName} from '${path}'`;
|
|
7510
|
+
}).join("\n");
|
|
7511
|
+
return `
|
|
7512
|
+
${importLines}
|
|
7513
|
+
|
|
7514
|
+
${toObject("PROXY_COMPONENTS", proxyComponents)}
|
|
7515
|
+
|
|
7516
|
+
${toObject("DIFF_COMPONENTS", diffComponents)}
|
|
7517
|
+
`;
|
|
7518
|
+
},
|
|
7519
|
+
() => {
|
|
7520
|
+
return `
|
|
7521
|
+
export declare const PROXY_COMPONENTS: Record<string, any>
|
|
7522
|
+
export declare const DIFF_COMPONENTS: Record<string, any>
|
|
7523
|
+
`;
|
|
7524
|
+
},
|
|
7525
|
+
{
|
|
7526
|
+
dependencies: ["block-path"]
|
|
7527
|
+
}
|
|
7528
|
+
);
|
|
7529
|
+
|
|
7530
|
+
function toStringUnion(strings) {
|
|
7531
|
+
return strings.sort().map((v) => `'${v}'`).join(" | ") || "never";
|
|
7532
|
+
}
|
|
7533
|
+
function getOptionTypes(definition, globalOptions) {
|
|
7534
|
+
const definedOptions = { ...definition.options || {} };
|
|
7535
|
+
const blockGlobalOptions = definition.globalOptions || [];
|
|
7536
|
+
blockGlobalOptions.forEach((key) => {
|
|
7537
|
+
if (globalOptions[key]) {
|
|
7538
|
+
definedOptions[key] = globalOptions[key];
|
|
7539
|
+
}
|
|
7540
|
+
});
|
|
7541
|
+
const options = Object.entries(definedOptions || {}).map(([key, option]) => {
|
|
7542
|
+
if (option.type === "checkbox") {
|
|
7543
|
+
return `${key}: '1' | '0' | undefined`;
|
|
7544
|
+
} else if (option.type === "text" || option.type === "radios" || option.type === "checkboxes" || option.type === "color" || option.type === "datetime-local") {
|
|
7545
|
+
return `${key}: string | undefined`;
|
|
7546
|
+
} else if (option.type === "range" || option.type === "number") {
|
|
7547
|
+
return `${key}: number | string | undefined`;
|
|
7548
|
+
}
|
|
7549
|
+
}).join("\n ");
|
|
7550
|
+
return `{
|
|
7551
|
+
${options}
|
|
7552
|
+
}`;
|
|
7553
|
+
}
|
|
7554
|
+
const generatedTypes = defineCodeTemplate(
|
|
7555
|
+
"generated-types",
|
|
7556
|
+
() => {
|
|
7557
|
+
return `export {}`;
|
|
7558
|
+
},
|
|
7559
|
+
(ctx) => {
|
|
7560
|
+
const mappedGetBundlePropsType = (bundle, file) => {
|
|
7561
|
+
if (bundle === "from_library" || bundle === "blokkli_fragment") {
|
|
7562
|
+
return {
|
|
7563
|
+
typeName: "Props",
|
|
7564
|
+
from: file.filePath
|
|
7565
|
+
};
|
|
7566
|
+
} else if (ctx.helper.options.getBundlePropsType) {
|
|
7567
|
+
return ctx.helper.options.getBundlePropsType(bundle, file);
|
|
7568
|
+
}
|
|
7569
|
+
return null;
|
|
7570
|
+
};
|
|
7571
|
+
const chunkNames = ctx.helper.options.chunkNames || ["global"];
|
|
7572
|
+
const fieldListTypes = ctx.helper.options.fieldListTypes || ["default"];
|
|
7573
|
+
const globalOptions = ctx.helper.options.globalOptions || {};
|
|
7574
|
+
const validGlobalOptions = Object.keys(globalOptions);
|
|
7575
|
+
const blockBundlesWithNested = [];
|
|
7576
|
+
const validBlockBundles = [];
|
|
7577
|
+
const propTypeImports = {};
|
|
7578
|
+
const propTypes = {};
|
|
7579
|
+
const typedFieldListItems = [];
|
|
7580
|
+
for (const file of ctx.blocks.files.values()) {
|
|
7581
|
+
if (!file.definition || !isBlock(file.definition)) {
|
|
7582
|
+
continue;
|
|
7583
|
+
}
|
|
7584
|
+
if (file.hasBlokkliField) {
|
|
7585
|
+
blockBundlesWithNested.push(file.definition.bundle);
|
|
7586
|
+
}
|
|
7587
|
+
if (file.definition.bundle !== "from_library") {
|
|
7588
|
+
validBlockBundles.push(file.definition.bundle);
|
|
7589
|
+
}
|
|
7590
|
+
if (!file.definition.renderFor) {
|
|
7591
|
+
const bundle = file.definition.bundle;
|
|
7592
|
+
const options = getOptionTypes(file.definition, globalOptions);
|
|
7593
|
+
const generatedTypeName = `FieldListItem_${bundle}`;
|
|
7594
|
+
const lines = [` bundle: '${bundle}'`, `options: ${options}`];
|
|
7595
|
+
const bundlePropsType = mappedGetBundlePropsType(bundle, file);
|
|
7596
|
+
if (bundlePropsType) {
|
|
7597
|
+
const { typeName, from } = bundlePropsType;
|
|
7598
|
+
if (!propTypeImports[from]) {
|
|
7599
|
+
propTypeImports[from] = [];
|
|
7600
|
+
}
|
|
7601
|
+
propTypeImports[from].push({ bundle, typeName });
|
|
7602
|
+
const tsTypeName = `Bundle_${bundle}_Props`;
|
|
7603
|
+
lines.push(`props: ${tsTypeName}`);
|
|
7604
|
+
propTypes[bundle] = tsTypeName;
|
|
7605
|
+
}
|
|
7606
|
+
const typeDefinition = `
|
|
7607
|
+
type ${generatedTypeName} = {
|
|
7608
|
+
${lines.join("\n ")}
|
|
7609
|
+
}`;
|
|
7610
|
+
typedFieldListItems.push({
|
|
7611
|
+
typeName: generatedTypeName,
|
|
7612
|
+
typeDefinition
|
|
7613
|
+
});
|
|
7614
|
+
}
|
|
7615
|
+
}
|
|
7616
|
+
const propTypeImportStatements = Object.entries(propTypeImports).map(([from, items]) => {
|
|
7617
|
+
const imports = items.map((v) => {
|
|
7618
|
+
return `${v.typeName} as Bundle_${v.bundle}_Props`;
|
|
7619
|
+
}).join(", ");
|
|
7620
|
+
const importPath = relative(ctx.helper.paths.blokkliBuildDir, from);
|
|
7621
|
+
return `import type { ${imports} } from '${importPath}'`;
|
|
7622
|
+
}).join("\n");
|
|
7623
|
+
const BundleProps = Object.entries(propTypes).map(([key, type]) => {
|
|
7624
|
+
return `'${key}': ${type}`;
|
|
7625
|
+
}).join("\n ");
|
|
7626
|
+
return `
|
|
7627
|
+
${propTypeImportStatements}
|
|
7628
|
+
import type { FieldListItem } from "${ctx.helper.relativePaths.TYPES}"
|
|
7629
|
+
|
|
7630
|
+
export type ValidFieldListTypes = ${toStringUnion(fieldListTypes)}
|
|
7631
|
+
|
|
7632
|
+
export type BlockBundle = ${toStringUnion(validBlockBundles)}
|
|
7633
|
+
|
|
7634
|
+
export type BlockBundleWithNested = ${toStringUnion(blockBundlesWithNested)}
|
|
7635
|
+
|
|
7636
|
+
export type ValidChunkNames = ${toStringUnion(chunkNames)}
|
|
7637
|
+
|
|
7638
|
+
export type BundleProps = {
|
|
7639
|
+
${BundleProps}
|
|
7640
|
+
}
|
|
7641
|
+
|
|
7642
|
+
export type GlobalOptionsKey = ${toStringUnion(validGlobalOptions)}
|
|
7643
|
+
|
|
7644
|
+
export type ValidGlobalConfigKeys = Array<GlobalOptionsKey>
|
|
7645
|
+
|
|
7646
|
+
${typedFieldListItems.map((v) => v.typeDefinition).join("\n\n")}
|
|
7647
|
+
|
|
7648
|
+
export type FieldListItemTyped = Omit<FieldListItem, 'props'> & (${typedFieldListItems.map((v) => v.typeName).sort().join(" | ")})
|
|
7649
|
+
export type FieldListItemTypedArray = Array<FieldListItemTyped>
|
|
7650
|
+
`;
|
|
7651
|
+
},
|
|
7652
|
+
{
|
|
7653
|
+
dependencies: ["block-path"]
|
|
7654
|
+
}
|
|
7655
|
+
);
|
|
7656
|
+
|
|
7657
|
+
const defaultGlobalOptions = defineCodeTemplate(
|
|
7658
|
+
"default-global-options",
|
|
7659
|
+
(ctx) => {
|
|
7660
|
+
const globalOptions = ctx.helper.options.globalOptions || {};
|
|
7661
|
+
const defaults = Object.entries(globalOptions).reduce(
|
|
7662
|
+
(acc, [key, option]) => {
|
|
7663
|
+
if (option.default !== void 0 && option.default !== null) {
|
|
7664
|
+
acc[key] = {
|
|
7665
|
+
default: option.default,
|
|
7666
|
+
type: option.type
|
|
7667
|
+
};
|
|
7668
|
+
}
|
|
7669
|
+
return acc;
|
|
7670
|
+
},
|
|
7671
|
+
{}
|
|
7672
|
+
);
|
|
7673
|
+
const bundlesWithVisibleLanguage = [];
|
|
7674
|
+
const bundlesWithHiddenGlobally = [];
|
|
7675
|
+
for (const file of ctx.blocks.files.values()) {
|
|
7676
|
+
if (!file.definition || !isBlock(file.definition)) {
|
|
7677
|
+
continue;
|
|
7678
|
+
}
|
|
7679
|
+
const usedGlobalOptions = file.definition.globalOptions || [];
|
|
7680
|
+
if (usedGlobalOptions.includes(BK_VISIBLE_LANGUAGES)) {
|
|
7681
|
+
bundlesWithVisibleLanguage.push(file.definition.bundle);
|
|
7682
|
+
}
|
|
7683
|
+
if (usedGlobalOptions.includes(BK_HIDDEN_GLOBALLY)) {
|
|
7684
|
+
bundlesWithHiddenGlobally.push(file.definition.bundle);
|
|
7685
|
+
}
|
|
7686
|
+
}
|
|
7687
|
+
return `
|
|
7688
|
+
export const bundlesWithVisibleLanguage = ${JSON.stringify(bundlesWithVisibleLanguage.sort())}
|
|
7689
|
+
export const bundlesWithHiddenGlobally = ${JSON.stringify(bundlesWithHiddenGlobally.sort())}
|
|
7690
|
+
|
|
7691
|
+
export const globalOptionsDefaults = ${JSON.stringify(defaults, null, 2)}`;
|
|
7692
|
+
},
|
|
7693
|
+
(ctx) => {
|
|
7694
|
+
return `
|
|
7695
|
+
import type { BlockOptionDefinition } from '${ctx.helper.relativePaths.TYPES_BLOKK_OPTIONS}'
|
|
7696
|
+
|
|
7697
|
+
type GlobalOptionsDefaults = {
|
|
7698
|
+
type: BlockOptionDefinition['type']
|
|
7699
|
+
default: any
|
|
7700
|
+
}
|
|
7701
|
+
|
|
7702
|
+
export declare const bundlesWithVisibleLanguage: string[]
|
|
7703
|
+
export declare const bundlesWithHiddenGlobally: string[]
|
|
7704
|
+
|
|
7705
|
+
export declare const globalOptionsDefaults: Record<string, GlobalOptionsDefaults>
|
|
7706
|
+
`;
|
|
7707
|
+
},
|
|
7708
|
+
{
|
|
7709
|
+
dependencies: ["block-path"]
|
|
7710
|
+
}
|
|
7711
|
+
);
|
|
7712
|
+
|
|
7713
|
+
const imports = defineCodeTemplate(
|
|
7714
|
+
"imports",
|
|
7715
|
+
(ctx) => {
|
|
7716
|
+
const chunkMapping = {};
|
|
7717
|
+
for (const file of ctx.blocks.files.values()) {
|
|
7718
|
+
if (!file.definition) {
|
|
7719
|
+
continue;
|
|
7720
|
+
}
|
|
7721
|
+
file.variations.forEach((variation) => {
|
|
7722
|
+
chunkMapping[variation] = file.chunkName;
|
|
7723
|
+
});
|
|
7724
|
+
}
|
|
7725
|
+
const lines = Object.entries(chunkMapping).map(
|
|
7726
|
+
([variation, importName]) => {
|
|
7727
|
+
return `'${variation}': '${importName}'`;
|
|
7728
|
+
}
|
|
7729
|
+
);
|
|
7730
|
+
const chunks = ctx.helper.getChunkNames().map((chunkName) => {
|
|
7731
|
+
if (chunkName === "global") {
|
|
7732
|
+
return null;
|
|
7733
|
+
}
|
|
7734
|
+
return `${chunkName}: () => import('#blokkli-build/chunk-${chunkName}.js').then(v => v['${chunkName}'])`;
|
|
7735
|
+
}).filter(falsy).sort().join(",\n ");
|
|
7736
|
+
return `
|
|
7737
|
+
import { global } from '#blokkli-build/chunk-global.js'
|
|
7738
|
+
|
|
7739
|
+
export const chunks = {
|
|
7740
|
+
global,
|
|
7741
|
+
${chunks}
|
|
7742
|
+
}
|
|
7743
|
+
|
|
7744
|
+
export const chunkMapping = {
|
|
7745
|
+
${lines.sort().join(",\n ")}
|
|
7746
|
+
}
|
|
7747
|
+
`;
|
|
7748
|
+
},
|
|
7749
|
+
() => {
|
|
7750
|
+
return `
|
|
7751
|
+
import type { Component } from 'vue'
|
|
7752
|
+
|
|
7753
|
+
export type ChunkGroup = Record<string, Component | { loadComponent: () => Promise<Component> } >
|
|
7754
|
+
export type ChunkGroupEntry = ChunkGroup | (() => Promise<ChunkGroup>)
|
|
7755
|
+
|
|
7756
|
+
/**
|
|
7757
|
+
* Mapping of block/fragment variation ID to a chunk group.
|
|
7758
|
+
*
|
|
7759
|
+
* The variation is only present if its chunkName is not 'global'.
|
|
7760
|
+
*/
|
|
7761
|
+
export declare const chunkMapping: Record<string, string>
|
|
7762
|
+
|
|
7763
|
+
/**
|
|
7764
|
+
* All available chunks.
|
|
7765
|
+
*/
|
|
7766
|
+
export declare const chunks: Record<string, ChunkGroupEntry>
|
|
7767
|
+
`;
|
|
7768
|
+
},
|
|
7769
|
+
{
|
|
7770
|
+
dependencies: ["block-path", "block-content"]
|
|
7771
|
+
}
|
|
7772
|
+
);
|
|
7773
|
+
|
|
7774
|
+
const optionsSchema = withHelper((helper) => {
|
|
7775
|
+
let fileName = "options-schema.json";
|
|
7776
|
+
const outputPath = helper.options.schemaOptionsPath;
|
|
7777
|
+
if (outputPath) {
|
|
7778
|
+
const resolved = resolveAlias(outputPath);
|
|
7779
|
+
fileName = helper.resolvers.src.resolve(resolved);
|
|
7780
|
+
}
|
|
7781
|
+
return defineFileTemplate(fileName, (ctx) => {
|
|
7782
|
+
const globalOptions = ctx.helper.options.globalOptions || {};
|
|
7783
|
+
const blocks = [...ctx.blocks.files.values()];
|
|
7784
|
+
const schema = blocks.reduce((acc, v) => {
|
|
7785
|
+
if (v.definition && isBlock(v.definition)) {
|
|
7786
|
+
const bundle = v.definition.bundle;
|
|
7787
|
+
const existing = acc[v.definition.bundle] || {};
|
|
7788
|
+
acc[v.definition.bundle] = defu(existing, v.definition.options || {});
|
|
7789
|
+
const globalOptionKeys = v.definition.globalOptions || [];
|
|
7790
|
+
globalOptionKeys.forEach((name) => {
|
|
7791
|
+
if (globalOptions[name]) {
|
|
7792
|
+
acc[bundle][name] = globalOptions[name];
|
|
7793
|
+
}
|
|
7794
|
+
});
|
|
7795
|
+
}
|
|
7796
|
+
return acc;
|
|
7797
|
+
}, {});
|
|
7798
|
+
const sorted = sortObjectKeys(schema);
|
|
7799
|
+
return JSON.stringify(sorted, null, 2);
|
|
7800
|
+
});
|
|
7801
|
+
});
|
|
7802
|
+
|
|
7803
|
+
const chunkGroup = withHelper((helper) => {
|
|
7804
|
+
return helper.getChunkNames().map((chunkName) => {
|
|
7805
|
+
return defineCodeTemplate(
|
|
7806
|
+
"chunk-" + chunkName,
|
|
7807
|
+
(ctx) => {
|
|
7808
|
+
const imports = [];
|
|
7809
|
+
const map = {};
|
|
7810
|
+
for (const file of ctx.blocks.files.values()) {
|
|
7811
|
+
if (!file.definition) {
|
|
7812
|
+
continue;
|
|
7813
|
+
}
|
|
7814
|
+
if (!fs.existsSync(file.filePath)) {
|
|
7815
|
+
continue;
|
|
7816
|
+
}
|
|
7817
|
+
if (file.chunkName !== chunkName) {
|
|
7818
|
+
continue;
|
|
7819
|
+
}
|
|
7820
|
+
if (helper.isDev) {
|
|
7821
|
+
imports.push(
|
|
7822
|
+
`const ${file.identifier} = () => import('${file.filePath}').then(v => v.default)`
|
|
7823
|
+
);
|
|
7824
|
+
file.variations.forEach((variation) => {
|
|
7825
|
+
map[variation] = `{ loadComponent: ${file.identifier} }`;
|
|
7826
|
+
});
|
|
7827
|
+
} else {
|
|
7828
|
+
imports.push(`import ${file.identifier} from '${file.filePath}'`);
|
|
7829
|
+
file.variations.forEach((variation) => {
|
|
7830
|
+
map[variation] = file.identifier;
|
|
7831
|
+
});
|
|
7832
|
+
}
|
|
7833
|
+
}
|
|
7834
|
+
const lines = Object.entries(map).map(([variation, importName]) => {
|
|
7835
|
+
return `'${variation}': ${importName}`;
|
|
7836
|
+
});
|
|
7837
|
+
return `
|
|
7838
|
+
${imports.sort().join("\n")}
|
|
7839
|
+
|
|
7840
|
+
export const ${chunkName} = {
|
|
7841
|
+
${lines.sort().join(",\n ")}
|
|
7842
|
+
}
|
|
7843
|
+
`;
|
|
7844
|
+
},
|
|
7845
|
+
() => {
|
|
7846
|
+
return `
|
|
7847
|
+
import type { Component } from 'vue'
|
|
7848
|
+
export declare const ${chunkName}: Record<string, { loadComponent: () => Promise<Component> } | Component>
|
|
7849
|
+
`;
|
|
7850
|
+
},
|
|
7851
|
+
{
|
|
7852
|
+
dependencies: ["block-path", "block-content"]
|
|
7853
|
+
}
|
|
7854
|
+
);
|
|
7855
|
+
});
|
|
7856
|
+
});
|
|
7857
|
+
|
|
7858
|
+
const TEMPLATES = [
|
|
7859
|
+
icons,
|
|
7860
|
+
features,
|
|
7861
|
+
featuresJson,
|
|
7862
|
+
translations,
|
|
7863
|
+
editAdapter,
|
|
7864
|
+
styles,
|
|
7865
|
+
config,
|
|
7866
|
+
definitions,
|
|
7867
|
+
moduleTypes,
|
|
7868
|
+
runtimeOptions,
|
|
7869
|
+
editComponents,
|
|
7870
|
+
generatedTypes,
|
|
7871
|
+
defaultGlobalOptions,
|
|
7872
|
+
imports,
|
|
7873
|
+
optionsSchema,
|
|
7874
|
+
chunkGroup
|
|
7875
|
+
];
|
|
7876
|
+
|
|
7877
|
+
class CollectedFeatureFile extends CollectedFile {
|
|
7878
|
+
definition = null;
|
|
7879
|
+
composableName = "defineBlokkliFeature";
|
|
7880
|
+
enabled = true;
|
|
7881
|
+
objectLiteral = void 0;
|
|
7882
|
+
getDefinition() {
|
|
7883
|
+
return this.definition;
|
|
7884
|
+
}
|
|
7885
|
+
async handleChange() {
|
|
7886
|
+
const objectLiteral = extractObjectLiteral(this.fileContents, [
|
|
7887
|
+
this.composableName
|
|
7888
|
+
]);
|
|
7889
|
+
if (this.objectLiteral === objectLiteral) {
|
|
7890
|
+
return false;
|
|
7011
7891
|
}
|
|
7012
|
-
|
|
7892
|
+
this.objectLiteral = objectLiteral;
|
|
7893
|
+
if (!this.objectLiteral) {
|
|
7894
|
+
return false;
|
|
7895
|
+
}
|
|
7896
|
+
try {
|
|
7897
|
+
const { object: definition, source } = parseTsObject(
|
|
7898
|
+
this.objectLiteral
|
|
7899
|
+
);
|
|
7900
|
+
const regex = /\/Features\/([^/]+)\//;
|
|
7901
|
+
const componentName = this.filePath.match(regex)?.[1] || "";
|
|
7902
|
+
this.definition = {
|
|
7903
|
+
id: definition.id,
|
|
7904
|
+
componentName,
|
|
7905
|
+
componentPath: this.filePath,
|
|
7906
|
+
definition,
|
|
7907
|
+
definitionSource: source
|
|
7908
|
+
};
|
|
7909
|
+
} catch (e) {
|
|
7910
|
+
console.error(
|
|
7911
|
+
`Failed to parse component "${this.filePath}": ${this.composableName} does not contain a valid object literal. No variables and methods are allowed inside ${this.composableName}().`,
|
|
7912
|
+
e
|
|
7913
|
+
);
|
|
7914
|
+
}
|
|
7915
|
+
return Promise.resolve(true);
|
|
7013
7916
|
}
|
|
7014
|
-
|
|
7015
|
-
|
|
7917
|
+
isEnabled() {
|
|
7918
|
+
return this.enabled;
|
|
7919
|
+
}
|
|
7920
|
+
/**
|
|
7921
|
+
* Disable the feature.
|
|
7922
|
+
*/
|
|
7923
|
+
disable() {
|
|
7924
|
+
this.enabled = false;
|
|
7925
|
+
}
|
|
7926
|
+
}
|
|
7927
|
+
class FeatureCollector extends Collector {
|
|
7928
|
+
needsFileContents = true;
|
|
7929
|
+
disabledFeatures = /* @__PURE__ */ new Set();
|
|
7930
|
+
srcFromModule;
|
|
7931
|
+
constructor(helper) {
|
|
7932
|
+
super(helper);
|
|
7933
|
+
this.srcFromModule = helper.resolvers.module.resolve(
|
|
7934
|
+
"./runtime/components/Edit/Features"
|
|
7935
|
+
);
|
|
7936
|
+
}
|
|
7937
|
+
getEnabledFeatures() {
|
|
7938
|
+
return [...this.files.values()].filter((v) => v.isEnabled()).map((v) => v.getDefinition()).filter(falsy).filter((v) => !this.disabledFeatures.has(v.id));
|
|
7939
|
+
}
|
|
7940
|
+
async init() {
|
|
7941
|
+
const builtinFeatures = await resolveFiles(
|
|
7942
|
+
this.srcFromModule,
|
|
7943
|
+
["*/index.vue"],
|
|
7944
|
+
{
|
|
7945
|
+
followSymbolicLinks: false
|
|
7946
|
+
}
|
|
7947
|
+
);
|
|
7948
|
+
const customFeatures = this.helper.options.featureImports ? await resolveFiles(
|
|
7949
|
+
this.helper.paths.srcDir,
|
|
7950
|
+
this.helper.options.featureImports,
|
|
7951
|
+
{
|
|
7952
|
+
followSymbolicLinks: false
|
|
7953
|
+
}
|
|
7954
|
+
) : [];
|
|
7955
|
+
await Promise.all(
|
|
7956
|
+
[...builtinFeatures, ...customFeatures].map((v) => this.addFile(v))
|
|
7957
|
+
);
|
|
7958
|
+
const features = [...this.files.values()];
|
|
7959
|
+
if (!this.helper.options.enableThemeEditor) {
|
|
7960
|
+
const themeFeature = features.find(
|
|
7961
|
+
(v) => v.getDefinition()?.id === "theme"
|
|
7962
|
+
);
|
|
7963
|
+
if (themeFeature) {
|
|
7964
|
+
themeFeature.disable();
|
|
7965
|
+
}
|
|
7966
|
+
}
|
|
7967
|
+
}
|
|
7968
|
+
runHooks() {
|
|
7969
|
+
return this.helper.nuxt.hooks.callHook("blokkli:alter-features", {
|
|
7970
|
+
features: [...this.files.values()]
|
|
7971
|
+
});
|
|
7972
|
+
}
|
|
7973
|
+
createCollectedFile(filePath, fileContents = "") {
|
|
7974
|
+
return new CollectedFeatureFile(filePath, fileContents);
|
|
7975
|
+
}
|
|
7976
|
+
applies(filePath) {
|
|
7977
|
+
return Promise.resolve(
|
|
7978
|
+
filePath.startsWith(this.srcFromModule) || micromatch.isMatch(filePath, "icon-blokkli-*.svg")
|
|
7979
|
+
);
|
|
7980
|
+
}
|
|
7981
|
+
getDependencyTypes() {
|
|
7982
|
+
return ["features"];
|
|
7983
|
+
}
|
|
7984
|
+
disableFeature(id) {
|
|
7985
|
+
this.disabledFeatures.add(id);
|
|
7986
|
+
}
|
|
7987
|
+
}
|
|
7016
7988
|
|
|
7017
7989
|
function hexToRgb(hex) {
|
|
7018
7990
|
if (hex.startsWith("#")) {
|
|
@@ -7026,21 +7998,6 @@ function hexToRgb(hex) {
|
|
|
7026
7998
|
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
7027
7999
|
return [r, g, b];
|
|
7028
8000
|
}
|
|
7029
|
-
function onlyUnique(value, index, self) {
|
|
7030
|
-
return self.indexOf(value) === index;
|
|
7031
|
-
}
|
|
7032
|
-
const fileExists = (path, extensions = ["js", "ts"]) => {
|
|
7033
|
-
if (!path) {
|
|
7034
|
-
return null;
|
|
7035
|
-
} else if (existsSync(path)) {
|
|
7036
|
-
return path;
|
|
7037
|
-
}
|
|
7038
|
-
const extension = extensions.find(
|
|
7039
|
-
(extension2) => existsSync(`${path}.${extension2}`)
|
|
7040
|
-
);
|
|
7041
|
-
return extension ? `${path}.${extension}` : null;
|
|
7042
|
-
};
|
|
7043
|
-
const POSSIBLE_EXTENSIONS = [".js", ".ts", ".vue", ".mjs"];
|
|
7044
8001
|
const buildThemeData = (themeOption) => {
|
|
7045
8002
|
const hasCustomTheme = !!themeOption;
|
|
7046
8003
|
const mergeTheme = createDefu((obj, key, value) => {
|
|
@@ -7077,17 +8034,29 @@ const buildThemeData = (themeOption) => {
|
|
|
7077
8034
|
);
|
|
7078
8035
|
return { themeCss, fullTheme, hasCustomTheme };
|
|
7079
8036
|
};
|
|
8037
|
+
class ThemeData {
|
|
8038
|
+
css;
|
|
8039
|
+
fullTheme;
|
|
8040
|
+
hasCustomTheme;
|
|
8041
|
+
constructor(helper) {
|
|
8042
|
+
const data = buildThemeData(helper.options.theme);
|
|
8043
|
+
this.css = data.themeCss;
|
|
8044
|
+
this.fullTheme = data.fullTheme;
|
|
8045
|
+
this.hasCustomTheme = data.hasCustomTheme;
|
|
8046
|
+
}
|
|
8047
|
+
}
|
|
8048
|
+
|
|
7080
8049
|
const module = defineNuxtModule({
|
|
7081
8050
|
meta: {
|
|
7082
8051
|
name: "blokkli",
|
|
7083
8052
|
configKey: "blokkli",
|
|
7084
8053
|
version,
|
|
7085
8054
|
compatibility: {
|
|
7086
|
-
nuxt: "^3.
|
|
8055
|
+
nuxt: "^3.15.0"
|
|
7087
8056
|
}
|
|
7088
8057
|
},
|
|
7089
8058
|
defaults: {
|
|
7090
|
-
pattern: ["components/Blokkli/**/*.
|
|
8059
|
+
pattern: ["components/Blokkli/**/*.vue"],
|
|
7091
8060
|
globalOptions: {
|
|
7092
8061
|
[BK_VISIBLE_LANGUAGES]: {
|
|
7093
8062
|
type: "checkboxes",
|
|
@@ -7105,490 +8074,82 @@ const module = defineNuxtModule({
|
|
|
7105
8074
|
itemEntityType: "block"
|
|
7106
8075
|
},
|
|
7107
8076
|
async setup(moduleOptions, nuxt) {
|
|
7108
|
-
const
|
|
7109
|
-
const
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
const buildResolver = createResolver(nuxt.options.buildDir);
|
|
7113
|
-
const blokkliBuildDir = buildResolver.resolve("blokkli");
|
|
7114
|
-
const IMPORTS = {
|
|
7115
|
-
TYPES: relative(
|
|
7116
|
-
blokkliBuildDir,
|
|
7117
|
-
resolver.resolve("./runtime/types/index.ts")
|
|
7118
|
-
),
|
|
7119
|
-
CONSTANTS: relative(
|
|
7120
|
-
blokkliBuildDir,
|
|
7121
|
-
resolver.resolve("./runtime/constants/index.ts")
|
|
7122
|
-
),
|
|
7123
|
-
ADAPTER: relative(
|
|
7124
|
-
blokkliBuildDir,
|
|
7125
|
-
resolver.resolve("./runtime/adapter/index.ts")
|
|
7126
|
-
),
|
|
7127
|
-
TYPES_THEME: relative(
|
|
7128
|
-
blokkliBuildDir,
|
|
7129
|
-
resolver.resolve("./runtime/types/theme.ts")
|
|
7130
|
-
),
|
|
7131
|
-
TYPES_GENERATED_MODULE_TYPED: relative(
|
|
7132
|
-
blokkliBuildDir,
|
|
7133
|
-
resolver.resolve("./runtime/types/generatedModuleTypes.ts")
|
|
7134
|
-
),
|
|
7135
|
-
TYPES_BLOKK_OPTIONS: relative(
|
|
7136
|
-
blokkliBuildDir,
|
|
7137
|
-
resolver.resolve("./runtime/types/blokkOptions.ts")
|
|
7138
|
-
)
|
|
7139
|
-
};
|
|
7140
|
-
const featureFolder = resolver.resolve("./runtime/components/Edit/Features");
|
|
7141
|
-
const featureExtractor = new Extractor(!nuxt.options.dev);
|
|
7142
|
-
const builtinFeatures = await resolveFiles(featureFolder, ["*/index.vue"], {
|
|
7143
|
-
followSymbolicLinks: false
|
|
7144
|
-
});
|
|
7145
|
-
const customFeatures = moduleOptions.featureImports ? await resolveFiles(srcDir, moduleOptions.featureImports, {
|
|
7146
|
-
followSymbolicLinks: false
|
|
7147
|
-
}) : [];
|
|
7148
|
-
await featureExtractor.addFiles([...builtinFeatures, ...customFeatures]);
|
|
7149
|
-
const extractedFeatures = featureExtractor.getFeatures();
|
|
7150
|
-
const features = extractedFeatures.filter((v) => {
|
|
7151
|
-
return v.id !== "theme" || moduleOptions.enableThemeEditor;
|
|
7152
|
-
});
|
|
7153
|
-
const featuresContext = {
|
|
7154
|
-
features
|
|
7155
|
-
};
|
|
7156
|
-
if (moduleOptions.alterFeatures) {
|
|
7157
|
-
featuresContext.features = await Promise.resolve(
|
|
7158
|
-
moduleOptions.alterFeatures(featuresContext)
|
|
7159
|
-
);
|
|
7160
|
-
}
|
|
7161
|
-
const allFeatureIds = [
|
|
7162
|
-
...extractedFeatures.map((v) => v.id),
|
|
7163
|
-
...featuresContext.features.map((v) => v.id)
|
|
7164
|
-
].filter(onlyUnique);
|
|
7165
|
-
const featureComponents = addTemplate({
|
|
7166
|
-
write: true,
|
|
7167
|
-
filename: "blokkli/features.ts",
|
|
7168
|
-
getContents: () => {
|
|
7169
|
-
const features2 = featuresContext.features.map((v) => {
|
|
7170
|
-
const importName = `Feature_${v.componentName}`;
|
|
7171
|
-
return {
|
|
7172
|
-
id: v.id,
|
|
7173
|
-
componentName: v.componentPath,
|
|
7174
|
-
importName,
|
|
7175
|
-
importStatement: `import ${importName} from '${relative(blokkliBuildDir, v.componentPath)}'`,
|
|
7176
|
-
definition: v.definition
|
|
7177
|
-
};
|
|
7178
|
-
});
|
|
7179
|
-
const imports = features2.map((v) => {
|
|
7180
|
-
return v.importStatement;
|
|
7181
|
-
}).join("\n");
|
|
7182
|
-
const availableFeaturesAtBuild = featuresContext.features.map(
|
|
7183
|
-
(v) => v.id
|
|
7184
|
-
);
|
|
7185
|
-
const featuresArray = features2.map((v) => {
|
|
7186
|
-
return `{
|
|
7187
|
-
id: "${v.id}",
|
|
7188
|
-
dependencies: ${JSON.stringify(v.definition.dependencies || [])},
|
|
7189
|
-
viewports: ${JSON.stringify(v.definition.viewports || [])},
|
|
7190
|
-
component: ${v.importName},
|
|
7191
|
-
requiredAdapterMethods: ${JSON.stringify(
|
|
7192
|
-
v.definition.requiredAdapterMethods || []
|
|
7193
|
-
)},
|
|
7194
|
-
label: ${JSON.stringify(v.definition.label || "")},
|
|
7195
|
-
beta: ${JSON.stringify(!!v.definition.beta)},
|
|
7196
|
-
description: "${v.definition.description || ""}"
|
|
7197
|
-
}`;
|
|
7198
|
-
}).join(",\n");
|
|
7199
|
-
return `${imports}
|
|
7200
|
-
import type { BlokkliAdapter } from '${IMPORTS.ADAPTER}'
|
|
7201
|
-
import type { Viewport } from '${IMPORTS.CONSTANTS}'
|
|
7202
|
-
type AdapterMethods = keyof BlokkliAdapter<any>
|
|
7203
|
-
|
|
7204
|
-
export const availableFeaturesAtBuild = ${JSON.stringify(
|
|
7205
|
-
availableFeaturesAtBuild
|
|
7206
|
-
)} as const
|
|
7207
|
-
|
|
7208
|
-
export type ValidFeatureKey = ${allFeatureIds.map((v) => '"' + v + '"').join(" | ")}
|
|
7209
|
-
|
|
7210
|
-
type FeatureComponent = {
|
|
7211
|
-
id: ValidFeatureKey
|
|
7212
|
-
component: any
|
|
7213
|
-
requiredAdapterMethods: AdapterMethods[]
|
|
7214
|
-
dependencies: ValidFeatureKey[]
|
|
7215
|
-
description: string
|
|
7216
|
-
label: string
|
|
7217
|
-
beta: boolean
|
|
7218
|
-
viewports: Viewport[]
|
|
7219
|
-
}
|
|
7220
|
-
|
|
7221
|
-
export const featureComponents: FeatureComponent[] = [
|
|
7222
|
-
${featuresArray}
|
|
7223
|
-
]
|
|
7224
|
-
`;
|
|
7225
|
-
},
|
|
7226
|
-
options: {
|
|
7227
|
-
blokkli: true
|
|
7228
|
-
}
|
|
7229
|
-
});
|
|
7230
|
-
nuxt.options.alias["#blokkli-build/features"] = featureComponents.dst;
|
|
7231
|
-
addTemplate({
|
|
7232
|
-
write: true,
|
|
7233
|
-
filename: "blokkli/features.json",
|
|
7234
|
-
getContents: async () => {
|
|
7235
|
-
const featuresData = await Promise.all(
|
|
7236
|
-
featuresContext.features.map(async (v) => {
|
|
7237
|
-
const docsPath = v.filePath.replace("index.vue", "docs.md");
|
|
7238
|
-
let docs = "";
|
|
7239
|
-
if (fileExists(docsPath)) {
|
|
7240
|
-
docs = await promises.readFile(docsPath).then((v2) => v2.toString());
|
|
7241
|
-
}
|
|
7242
|
-
return {
|
|
7243
|
-
...v,
|
|
7244
|
-
repoRelativePath: v.filePath.replace(/.*\/src/, "/src"),
|
|
7245
|
-
docs
|
|
7246
|
-
};
|
|
7247
|
-
})
|
|
7248
|
-
);
|
|
7249
|
-
return JSON.stringify(featuresData, null, 2);
|
|
7250
|
-
},
|
|
7251
|
-
options: {
|
|
7252
|
-
blokkli: true
|
|
7253
|
-
}
|
|
7254
|
-
});
|
|
7255
|
-
function getChunkNames() {
|
|
7256
|
-
const chunkNames = [...moduleOptions.chunkNames || []];
|
|
7257
|
-
if (!chunkNames.includes("global")) {
|
|
7258
|
-
chunkNames.push("global");
|
|
7259
|
-
}
|
|
7260
|
-
return chunkNames.filter(onlyUnique);
|
|
7261
|
-
}
|
|
7262
|
-
function getFieldListTypes() {
|
|
7263
|
-
const types = [...moduleOptions.fieldListTypes || []];
|
|
7264
|
-
if (!types.includes("default")) {
|
|
7265
|
-
types.push("default");
|
|
8077
|
+
const blokkliModules = moduleOptions.modules || [];
|
|
8078
|
+
for (const module of blokkliModules) {
|
|
8079
|
+
if (module.init.alterOptions) {
|
|
8080
|
+
module.init.alterOptions(moduleOptions);
|
|
7266
8081
|
}
|
|
7267
|
-
return types.filter(onlyUnique);
|
|
7268
|
-
}
|
|
7269
|
-
const importPattern = moduleOptions.pattern || [];
|
|
7270
|
-
const featureIsEnabled = (id) => featuresContext.features.some((v) => v.id === id);
|
|
7271
|
-
if (featureIsEnabled("library")) {
|
|
7272
|
-
importPattern.push(
|
|
7273
|
-
resolver.resolve("./runtime/components/Blocks/FromLibrary/*.vue")
|
|
7274
|
-
);
|
|
7275
|
-
}
|
|
7276
|
-
if (featureIsEnabled("fragments")) {
|
|
7277
|
-
importPattern.push(
|
|
7278
|
-
resolver.resolve("./runtime/components/Blocks/Fragment/*.vue")
|
|
7279
|
-
);
|
|
7280
8082
|
}
|
|
7281
|
-
const
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
const
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
8083
|
+
const helper = new ModuleHelper(nuxt, import.meta.url, moduleOptions);
|
|
8084
|
+
const theme = new ThemeData(helper);
|
|
8085
|
+
const iconCollector = new IconCollector(helper);
|
|
8086
|
+
const featureCollector = new FeatureCollector(helper);
|
|
8087
|
+
const blockCollector = new BlockCollector(helper);
|
|
8088
|
+
const collectors = [
|
|
8089
|
+
iconCollector,
|
|
8090
|
+
featureCollector,
|
|
8091
|
+
blockCollector
|
|
8092
|
+
];
|
|
8093
|
+
await Promise.all(collectors.map((v) => v.init()));
|
|
8094
|
+
await Promise.all(collectors.map((v) => v.runHooks()));
|
|
8095
|
+
const context = new ModuleContext(
|
|
8096
|
+
helper,
|
|
8097
|
+
iconCollector,
|
|
8098
|
+
featureCollector,
|
|
8099
|
+
blockCollector,
|
|
8100
|
+
theme
|
|
7288
8101
|
);
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
nuxt.options.alias["#blokkli-build/definitions"] = templateDefinitions.dst;
|
|
7303
|
-
const templateRuntimeOptions = addTemplate({
|
|
7304
|
-
write: true,
|
|
7305
|
-
filename: "blokkli/runtime-options.ts",
|
|
7306
|
-
getContents: () => {
|
|
7307
|
-
return blockExtractor.generateRuntimeOptionsTemplate(
|
|
7308
|
-
moduleOptions.globalOptions
|
|
7309
|
-
);
|
|
7310
|
-
},
|
|
7311
|
-
options: {
|
|
7312
|
-
blokkli: true
|
|
7313
|
-
}
|
|
7314
|
-
});
|
|
7315
|
-
nuxt.options.alias["#blokkli-build/runtime-options"] = templateRuntimeOptions.dst;
|
|
7316
|
-
const templateEditComponents = addTemplate({
|
|
7317
|
-
write: true,
|
|
7318
|
-
filename: "blokkli/edit-components.ts",
|
|
7319
|
-
getContents: () => {
|
|
7320
|
-
return blockExtractor.generateEditComponents();
|
|
7321
|
-
},
|
|
7322
|
-
options: {
|
|
7323
|
-
blokkli: true
|
|
7324
|
-
}
|
|
7325
|
-
});
|
|
7326
|
-
nuxt.options.alias["#blokkli-build/edit-components"] = templateEditComponents.dst;
|
|
7327
|
-
const templateTranslations = addTemplate({
|
|
7328
|
-
write: true,
|
|
7329
|
-
filename: "blokkli/translations.ts",
|
|
7330
|
-
getContents: () => {
|
|
7331
|
-
const translations$1 = {};
|
|
7332
|
-
Object.keys(translations).forEach((language) => {
|
|
7333
|
-
translations$1[language] = {};
|
|
7334
|
-
Object.keys(translations[language]).forEach((key) => {
|
|
7335
|
-
translations$1[language][key] = translations[language][key].translation;
|
|
7336
|
-
});
|
|
8102
|
+
const app = {
|
|
8103
|
+
helper,
|
|
8104
|
+
context
|
|
8105
|
+
};
|
|
8106
|
+
for (const module of blokkliModules) {
|
|
8107
|
+
await module.init.setup(app, module.options);
|
|
8108
|
+
}
|
|
8109
|
+
TEMPLATES.forEach((v) => {
|
|
8110
|
+
if (typeof v === "function") {
|
|
8111
|
+
const result = v(helper);
|
|
8112
|
+
const templates = Array.isArray(result) ? result : [result];
|
|
8113
|
+
templates.forEach((template) => {
|
|
8114
|
+
context.addTemplate(template);
|
|
7337
8115
|
});
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
},
|
|
7341
|
-
options: {
|
|
7342
|
-
blokkli: true
|
|
8116
|
+
} else {
|
|
8117
|
+
context.addTemplate(v);
|
|
7343
8118
|
}
|
|
7344
8119
|
});
|
|
7345
|
-
|
|
8120
|
+
await context.generateTemplates();
|
|
8121
|
+
helper.addAlias("#blokkli-build", helper.paths.blokkliBuildDir);
|
|
8122
|
+
const moduleDir = import.meta.url;
|
|
8123
|
+
const resolver = createResolver(moduleDir);
|
|
7346
8124
|
nuxt.options.runtimeConfig.public.blokkli = {
|
|
7347
8125
|
itemEntityType: moduleOptions.itemEntityType || "",
|
|
7348
8126
|
defaultLanguage: moduleOptions.defaultLanguage || "en"
|
|
7349
8127
|
};
|
|
7350
|
-
const resolvedPath = "~/app/blokkli.editAdapter".replace(/^(~~|@@)/, nuxt.options.rootDir).replace(/^(~|@)/, nuxt.options.srcDir);
|
|
7351
|
-
const adapterTemplate = (() => {
|
|
7352
|
-
const resolvedFilename = `blokkli/editAdapter.ts`;
|
|
7353
|
-
const maybeUserFile = fileExists(resolvedPath, ["ts"]);
|
|
7354
|
-
if (!maybeUserFile) {
|
|
7355
|
-
throw new Error(
|
|
7356
|
-
"Missing blokkli adapter file in ~/app/blokkli.editAdapter.ts"
|
|
7357
|
-
);
|
|
7358
|
-
}
|
|
7359
|
-
return addTemplate({
|
|
7360
|
-
filename: resolvedFilename,
|
|
7361
|
-
write: true,
|
|
7362
|
-
getContents: () => `
|
|
7363
|
-
import type { BlokkliAdapterFactory } from '${IMPORTS.ADAPTER}'
|
|
7364
|
-
import adapter from '${relative(blokkliBuildDir, resolvedPath)}'
|
|
7365
|
-
|
|
7366
|
-
export default adapter as BlokkliAdapterFactory<any>
|
|
7367
|
-
`
|
|
7368
|
-
});
|
|
7369
|
-
})();
|
|
7370
|
-
nuxt.options.alias["#blokkli-build/compiled-edit-adapter"] = adapterTemplate.dst;
|
|
7371
8128
|
nuxt.options.build.transpile.push(resolver.resolve("runtime"));
|
|
7372
|
-
addComponent(
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
});
|
|
7387
|
-
addComponent({
|
|
7388
|
-
filePath: resolver.resolve("./runtime/components/BlokkliItem"),
|
|
7389
|
-
name: "BlokkliItem",
|
|
7390
|
-
global: true
|
|
7391
|
-
});
|
|
7392
|
-
addBuildPlugin(DefinitionPlugin(nuxt));
|
|
7393
|
-
addImports({
|
|
7394
|
-
name: "defineBlokkli",
|
|
7395
|
-
from: resolver.resolve("./runtime/composables/defineBlokkli"),
|
|
7396
|
-
as: "defineBlokkli"
|
|
7397
|
-
});
|
|
7398
|
-
addImports({
|
|
7399
|
-
name: "defineBlokkliFragment",
|
|
7400
|
-
from: resolver.resolve("./runtime/composables/defineBlokkliFragment"),
|
|
7401
|
-
as: "defineBlokkliFragment"
|
|
7402
|
-
});
|
|
7403
|
-
addImports({
|
|
7404
|
-
name: "defineBlokkliFeature",
|
|
7405
|
-
from: resolver.resolve("./runtime/composables/defineBlokkliFeature"),
|
|
7406
|
-
as: "defineBlokkliFeature"
|
|
7407
|
-
});
|
|
7408
|
-
addImports({
|
|
7409
|
-
name: "useBlokkli",
|
|
7410
|
-
from: resolver.resolve("./runtime/composables/useBlokkli"),
|
|
7411
|
-
as: "useBlokkli"
|
|
7412
|
-
});
|
|
7413
|
-
nuxt.options.alias["#blokkli-build/styles"] = resolver.resolve(
|
|
7414
|
-
"./runtime/css/output.css"
|
|
7415
|
-
);
|
|
7416
|
-
const templateGeneratedTypes = addTemplate({
|
|
7417
|
-
write: true,
|
|
7418
|
-
filename: "blokkli/generated-types.ts",
|
|
7419
|
-
getContents: () => {
|
|
7420
|
-
return blockExtractor.generateTypesTemplate(
|
|
7421
|
-
moduleOptions.globalOptions || {},
|
|
7422
|
-
getChunkNames(),
|
|
7423
|
-
getFieldListTypes(),
|
|
7424
|
-
moduleOptions.getBundlePropsType
|
|
7425
|
-
);
|
|
7426
|
-
},
|
|
7427
|
-
options: {
|
|
7428
|
-
blokkli: true
|
|
7429
|
-
}
|
|
7430
|
-
});
|
|
7431
|
-
nuxt.options.alias["#blokkli-build/generated-types"] = templateGeneratedTypes.dst;
|
|
7432
|
-
const { themeCss, fullTheme, hasCustomTheme } = buildThemeData(
|
|
7433
|
-
moduleOptions.theme
|
|
7434
|
-
);
|
|
7435
|
-
const templateThemeCss = addTemplate({
|
|
7436
|
-
write: true,
|
|
7437
|
-
filename: "blokkli/theme.css",
|
|
7438
|
-
getContents: () => {
|
|
7439
|
-
return themeCss;
|
|
7440
|
-
},
|
|
7441
|
-
options: {
|
|
7442
|
-
blokkli: true
|
|
7443
|
-
}
|
|
7444
|
-
});
|
|
7445
|
-
nuxt.options.alias["#blokkli-build/theme"] = templateThemeCss.dst;
|
|
7446
|
-
const templateConfig = addTemplate({
|
|
7447
|
-
write: true,
|
|
7448
|
-
filename: "blokkli/config.ts",
|
|
7449
|
-
getContents: () => {
|
|
7450
|
-
const settingsOverride = moduleOptions.settingsOverride || {};
|
|
7451
|
-
return `import type { Theme } from '${IMPORTS.TYPES_THEME}'
|
|
7452
|
-
import type { ModuleOptionsSettings } from '${IMPORTS.TYPES_GENERATED_MODULE_TYPED}'
|
|
7453
|
-
|
|
7454
|
-
export const hasCustomTheme = ${JSON.stringify(hasCustomTheme)}
|
|
7455
|
-
export const themes: Record<string, Theme> = ${JSON.stringify(themes, null, 2)}
|
|
7456
|
-
export const theme: Theme = ${JSON.stringify(fullTheme, null, 2)}
|
|
7457
|
-
|
|
7458
|
-
export const settingsOverride: ModuleOptionsSettings = ${JSON.stringify(
|
|
7459
|
-
settingsOverride
|
|
7460
|
-
)}
|
|
7461
|
-
|
|
7462
|
-
export const blokkliVersion = ${JSON.stringify(version)}
|
|
7463
|
-
|
|
7464
|
-
export const storageDefaults: Record<string, string|boolean|string[]> = ${JSON.stringify(
|
|
7465
|
-
moduleOptions.storageDefaults || {}
|
|
7466
|
-
)}
|
|
7467
|
-
export const defaultLanguage: string = ${JSON.stringify(
|
|
7468
|
-
moduleOptions.defaultLanguage || "en"
|
|
7469
|
-
)}
|
|
7470
|
-
export const forceDefaultLanguage: boolean = ${JSON.stringify(
|
|
7471
|
-
!!moduleOptions.forceDefaultLanguage
|
|
7472
|
-
)}
|
|
7473
|
-
`;
|
|
7474
|
-
},
|
|
7475
|
-
options: {
|
|
7476
|
-
blokkli: true
|
|
7477
|
-
}
|
|
7478
|
-
});
|
|
7479
|
-
nuxt.options.alias["#blokkli-build/config"] = templateConfig.dst;
|
|
7480
|
-
const templateDefaultGlobalOptions = addTemplate({
|
|
7481
|
-
write: true,
|
|
7482
|
-
filename: "blokkli/default-global-options.ts",
|
|
7483
|
-
getContents: () => {
|
|
7484
|
-
return blockExtractor.generateDefaultGlobalOptions(
|
|
7485
|
-
moduleOptions.globalOptions || {}
|
|
7486
|
-
);
|
|
7487
|
-
},
|
|
7488
|
-
options: {
|
|
7489
|
-
blokkli: true
|
|
7490
|
-
}
|
|
7491
|
-
});
|
|
7492
|
-
nuxt.options.alias["#blokkli-build/default-global-options"] = templateDefaultGlobalOptions.dst;
|
|
7493
|
-
let optionsSchemaTemplate = null;
|
|
7494
|
-
const generateOptionsSchema = async () => {
|
|
7495
|
-
const outputPath = moduleOptions.schemaOptionsPath;
|
|
7496
|
-
if (outputPath) {
|
|
7497
|
-
const resolvedPath2 = await srcResolver.resolvePath(outputPath);
|
|
7498
|
-
const content = blockExtractor.generateOptionsSchema(
|
|
7499
|
-
moduleOptions.globalOptions || {}
|
|
7500
|
-
);
|
|
7501
|
-
return promises.writeFile(resolvedPath2, content);
|
|
7502
|
-
}
|
|
7503
|
-
if (optionsSchemaTemplate) {
|
|
7504
|
-
return;
|
|
7505
|
-
}
|
|
7506
|
-
optionsSchemaTemplate = addTemplate({
|
|
7507
|
-
write: true,
|
|
7508
|
-
filename: "blokkli/options-schema.json",
|
|
7509
|
-
getContents: () => {
|
|
7510
|
-
return blockExtractor.generateOptionsSchema(
|
|
7511
|
-
moduleOptions.globalOptions || {}
|
|
7512
|
-
);
|
|
7513
|
-
},
|
|
7514
|
-
options: {
|
|
7515
|
-
blokkli: true
|
|
7516
|
-
}
|
|
7517
|
-
});
|
|
7518
|
-
};
|
|
7519
|
-
await generateOptionsSchema();
|
|
7520
|
-
getChunkNames().forEach((chunkName) => {
|
|
7521
|
-
if (chunkName !== "global" && !nuxt.options.dev) {
|
|
7522
|
-
addTemplate({
|
|
7523
|
-
write: true,
|
|
7524
|
-
filename: `blokkli/chunk-${chunkName}.ts`,
|
|
7525
|
-
getContents: () => {
|
|
7526
|
-
return blockExtractor.generateChunkGroupTemplate(chunkName);
|
|
7527
|
-
},
|
|
7528
|
-
options: {
|
|
7529
|
-
blokkli: true
|
|
7530
|
-
}
|
|
7531
|
-
});
|
|
7532
|
-
}
|
|
7533
|
-
});
|
|
7534
|
-
const templateImports = addTemplate({
|
|
7535
|
-
write: true,
|
|
7536
|
-
filename: "blokkli/imports.ts",
|
|
7537
|
-
getContents: () => {
|
|
7538
|
-
return blockExtractor.generateImportsTemplate(
|
|
7539
|
-
nuxt.options.dev ? ["global"] : getChunkNames()
|
|
7540
|
-
);
|
|
7541
|
-
},
|
|
7542
|
-
options: {
|
|
7543
|
-
blokkli: true
|
|
7544
|
-
}
|
|
7545
|
-
});
|
|
7546
|
-
const templateIcons = addTemplate({
|
|
7547
|
-
write: true,
|
|
7548
|
-
filename: "blokkli/icons.ts",
|
|
7549
|
-
getContents: async () => {
|
|
7550
|
-
const pathModule = resolver.resolve("./runtime/icons");
|
|
7551
|
-
const filesModule = await resolveFiles(pathModule, "*.svg");
|
|
7552
|
-
const filesApp = await resolveFiles(
|
|
7553
|
-
srcDir,
|
|
7554
|
-
"components/**/icon-blokkli-*.svg"
|
|
7555
|
-
);
|
|
7556
|
-
const icons = await Promise.all(
|
|
7557
|
-
[...filesModule, ...filesApp].map((filePath) => {
|
|
7558
|
-
return promises.readFile(filePath).then((data) => {
|
|
7559
|
-
const name = basename(filePath, ".svg").toLowerCase();
|
|
7560
|
-
return {
|
|
7561
|
-
markup: data.toString(),
|
|
7562
|
-
name
|
|
7563
|
-
};
|
|
7564
|
-
});
|
|
7565
|
-
})
|
|
7566
|
-
);
|
|
7567
|
-
const iconMap = icons.reduce((acc, v) => {
|
|
7568
|
-
acc[v.name] = v.markup;
|
|
7569
|
-
return acc;
|
|
7570
|
-
}, {});
|
|
7571
|
-
return `export const icons = ${JSON.stringify(iconMap)} as const
|
|
7572
|
-
export type BlokkliIcon = keyof typeof icons`;
|
|
7573
|
-
},
|
|
7574
|
-
options: {
|
|
7575
|
-
blokkli: true
|
|
7576
|
-
}
|
|
7577
|
-
});
|
|
7578
|
-
nuxt.options.alias["#blokkli-build/icons"] = templateIcons.dst;
|
|
7579
|
-
nuxt.options.alias["#blokkli-build/imports"] = templateImports.dst;
|
|
7580
|
-
nuxt.options.alias["#blokkli/types"] = resolver.resolve("runtime/types");
|
|
7581
|
-
nuxt.options.alias["#blokkli/constants"] = resolver.resolve("runtime/constants");
|
|
7582
|
-
nuxt.options.alias["#blokkli/plugins"] = resolver.resolve(
|
|
7583
|
-
"runtime/blokkliPlugins"
|
|
8129
|
+
helper.addComponent("BlokkliField");
|
|
8130
|
+
helper.addComponent("BlokkliEditable");
|
|
8131
|
+
helper.addComponent("BlokkliProvider");
|
|
8132
|
+
helper.addComponent("BlokkliItem");
|
|
8133
|
+
helper.addComposable("defineBlokkli");
|
|
8134
|
+
helper.addComposable("defineBlokkliFragment");
|
|
8135
|
+
helper.addComposable("defineBlokkliFeature");
|
|
8136
|
+
helper.addComposable("useBlokkli");
|
|
8137
|
+
helper.addAlias("#blokkli-build", helper.paths.blokkliBuildDir);
|
|
8138
|
+
helper.addAlias("#blokkli/types", resolver.resolve("runtime/types"));
|
|
8139
|
+
helper.addAlias("#blokkli/constants", resolver.resolve("runtime/constants"));
|
|
8140
|
+
helper.addAlias(
|
|
8141
|
+
"#blokkli/plugins",
|
|
8142
|
+
resolver.resolve("runtime/blokkliPlugins")
|
|
7584
8143
|
);
|
|
7585
|
-
|
|
7586
|
-
"
|
|
8144
|
+
helper.addAlias(
|
|
8145
|
+
"#blokkli/components",
|
|
8146
|
+
resolver.resolve("runtime/components/Edit")
|
|
7587
8147
|
);
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
"runtime
|
|
8148
|
+
helper.addAlias("#blokkli/helpers", resolver.resolve("runtime/helpers"));
|
|
8149
|
+
helper.addAlias("#blokkli/adapter", resolver.resolve("runtime/adapter"));
|
|
8150
|
+
helper.addAlias(
|
|
8151
|
+
"#blokkli/runtime-helpers",
|
|
8152
|
+
resolver.resolve("runtime/helpers/runtimeHelpers")
|
|
7592
8153
|
);
|
|
7593
8154
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
7594
8155
|
nitroConfig.publicAssets ||= [];
|
|
@@ -7601,43 +8162,22 @@ export type BlokkliIcon = keyof typeof icons`;
|
|
|
7601
8162
|
addPlugin({
|
|
7602
8163
|
src: resolver.resolve("runtime/plugins/blokkliEditable")
|
|
7603
8164
|
});
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
if (!POSSIBLE_EXTENSIONS.includes(extname(filePath))) {
|
|
7607
|
-
return Promise.resolve(void 0);
|
|
7608
|
-
}
|
|
7609
|
-
return resolveFiles(srcDir, importPattern, {
|
|
7610
|
-
followSymbolicLinks: false
|
|
7611
|
-
}).then((files2) => {
|
|
7612
|
-
return files2.find((v) => v === filePath);
|
|
7613
|
-
});
|
|
7614
|
-
};
|
|
8165
|
+
addBuildPlugin(RuntimeDefinitionPlugin(nuxt, "defineBlokkli"));
|
|
8166
|
+
addBuildPlugin(RuntimeDefinitionPlugin(nuxt, "defineBlokkliFragment"));
|
|
7615
8167
|
if (nuxt.options.dev) {
|
|
7616
|
-
nuxt.hook("
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
return;
|
|
7625
|
-
}
|
|
7626
|
-
await updateTemplates({
|
|
7627
|
-
filter: (template) => {
|
|
7628
|
-
return template.options && template.options.blokkli;
|
|
7629
|
-
}
|
|
7630
|
-
});
|
|
7631
|
-
await generateOptionsSchema();
|
|
7632
|
-
const modules = viteServer.moduleGraph.getModulesByFile(
|
|
7633
|
-
templateDefinitions.dst
|
|
7634
|
-
);
|
|
7635
|
-
if (modules) {
|
|
7636
|
-
modules.forEach((v) => {
|
|
7637
|
-
viteServer.reloadModule(v);
|
|
7638
|
-
});
|
|
8168
|
+
nuxt.hook("builder:watch", async (event, providedFilePath) => {
|
|
8169
|
+
const filePath = providedFilePath.startsWith("/") ? providedFilePath : helper.resolvers.src.resolve(providedFilePath);
|
|
8170
|
+
helper.fileCache.handleWatchEvent(event, filePath);
|
|
8171
|
+
const dependenciesToUpdate = [];
|
|
8172
|
+
for (const collector of collectors) {
|
|
8173
|
+
const result = await collector.handleWatchEvent(event, filePath);
|
|
8174
|
+
if (result.hasChanged) {
|
|
8175
|
+
dependenciesToUpdate.push(...collector.getDependencyTypes());
|
|
7639
8176
|
}
|
|
7640
|
-
}
|
|
8177
|
+
}
|
|
8178
|
+
if (dependenciesToUpdate.length) {
|
|
8179
|
+
await context.generateTemplates(dependenciesToUpdate);
|
|
8180
|
+
}
|
|
7641
8181
|
});
|
|
7642
8182
|
}
|
|
7643
8183
|
}
|