nebula-cms 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/astro/index.d.ts +43 -0
- package/dist/astro/index.d.ts.map +1 -0
- package/dist/astro/index.js +223 -0
- package/{src → dist}/client/Admin.svelte +20 -11
- package/dist/client/Admin.svelte.d.ts +11 -0
- package/dist/client/Admin.svelte.d.ts.map +1 -0
- package/dist/client/components/BackendPicker.svelte.d.ts +4 -0
- package/dist/client/components/BackendPicker.svelte.d.ts.map +1 -0
- package/dist/client/components/DraftChip.svelte.d.ts +10 -0
- package/dist/client/components/DraftChip.svelte.d.ts.map +1 -0
- package/dist/client/components/MetadataForm.svelte.d.ts +12 -0
- package/dist/client/components/MetadataForm.svelte.d.ts.map +1 -0
- package/dist/client/components/ThemeToggle.svelte.d.ts +19 -0
- package/dist/client/components/ThemeToggle.svelte.d.ts.map +1 -0
- package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts +11 -0
- package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts.map +1 -0
- package/{src → dist}/client/components/dialogs/FilenameDialog.svelte +1 -2
- package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts +13 -0
- package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorPane.svelte.d.ts +4 -0
- package/dist/client/components/editor/EditorPane.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorTabs.svelte.d.ts +8 -0
- package/dist/client/components/editor/EditorTabs.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorToolbar.svelte.d.ts +4 -0
- package/dist/client/components/editor/EditorToolbar.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/FormatSelector.svelte.d.ts +4 -0
- package/dist/client/components/editor/FormatSelector.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/Toolbar.svelte.d.ts +19 -0
- package/dist/client/components/editor/Toolbar.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ArrayField.svelte.d.ts +15 -0
- package/dist/client/components/fields/ArrayField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ArrayItem.svelte.d.ts +28 -0
- package/dist/client/components/fields/ArrayItem.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/BooleanField.svelte.d.ts +16 -0
- package/dist/client/components/fields/BooleanField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/DateField.svelte.d.ts +16 -0
- package/dist/client/components/fields/DateField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/EnumField.svelte.d.ts +17 -0
- package/dist/client/components/fields/EnumField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/FieldWrapper.svelte.d.ts +18 -0
- package/dist/client/components/fields/FieldWrapper.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/NumberField.svelte.d.ts +16 -0
- package/dist/client/components/fields/NumberField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ObjectField.svelte.d.ts +16 -0
- package/dist/client/components/fields/ObjectField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/SchemaField.svelte.d.ts +16 -0
- package/dist/client/components/fields/SchemaField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/StringField.svelte.d.ts +16 -0
- package/dist/client/components/fields/StringField.svelte.d.ts.map +1 -0
- package/{src → dist}/client/components/sidebar/AdminSidebar.svelte +2 -4
- package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts +19 -0
- package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts.map +1 -0
- package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts +12 -0
- package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts.map +1 -0
- package/dist/client/css/icons.css +29 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/js/drafts/merge.svelte.d.ts +24 -0
- package/dist/client/js/drafts/merge.svelte.d.ts.map +1 -0
- package/dist/client/js/drafts/merge.svelte.js +106 -0
- package/dist/client/js/drafts/ops.svelte.d.ts +31 -0
- package/dist/client/js/drafts/ops.svelte.d.ts.map +1 -0
- package/dist/client/js/drafts/ops.svelte.js +182 -0
- package/dist/client/js/drafts/storage.d.ts +45 -0
- package/dist/client/js/drafts/storage.d.ts.map +1 -0
- package/dist/client/js/drafts/storage.js +76 -0
- package/dist/client/js/drafts/workers/diff.d.ts +2 -0
- package/dist/client/js/drafts/workers/diff.d.ts.map +1 -0
- package/dist/client/js/drafts/workers/diff.js +20 -0
- package/dist/client/js/editor/editor.svelte.d.ts +124 -0
- package/dist/client/js/editor/editor.svelte.d.ts.map +1 -0
- package/dist/client/js/editor/editor.svelte.js +294 -0
- package/dist/client/js/editor/languages.d.ts +11 -0
- package/dist/client/js/editor/languages.d.ts.map +1 -0
- package/dist/client/js/editor/languages.js +93 -0
- package/dist/client/js/editor/link-wrap.d.ts +6 -0
- package/dist/client/js/editor/link-wrap.d.ts.map +1 -0
- package/{src/client/js/editor/link-wrap.ts → dist/client/js/editor/link-wrap.js} +17 -24
- package/dist/client/js/editor/markdown-shortcuts.d.ts +4 -0
- package/dist/client/js/editor/markdown-shortcuts.d.ts.map +1 -0
- package/dist/client/js/editor/markdown-shortcuts.js +219 -0
- package/dist/client/js/handlers/admin.d.ts +64 -0
- package/dist/client/js/handlers/admin.d.ts.map +1 -0
- package/dist/client/js/handlers/admin.js +186 -0
- package/dist/client/js/state/dialogs.svelte.d.ts +16 -0
- package/dist/client/js/state/dialogs.svelte.d.ts.map +1 -0
- package/dist/client/js/state/dialogs.svelte.js +28 -0
- package/dist/client/js/state/router.svelte.d.ts +44 -0
- package/dist/client/js/state/router.svelte.d.ts.map +1 -0
- package/dist/client/js/state/router.svelte.js +141 -0
- package/dist/client/js/state/schema.svelte.d.ts +51 -0
- package/dist/client/js/state/schema.svelte.d.ts.map +1 -0
- package/{src/client/js/state/schema.svelte.ts → dist/client/js/state/schema.svelte.js} +55 -70
- package/dist/client/js/state/state.svelte.d.ts +68 -0
- package/dist/client/js/state/state.svelte.d.ts.map +1 -0
- package/dist/client/js/state/state.svelte.js +300 -0
- package/dist/client/js/state/theme.svelte.d.ts +24 -0
- package/dist/client/js/state/theme.svelte.d.ts.map +1 -0
- package/{src/client/js/state/theme.svelte.ts → dist/client/js/state/theme.svelte.js} +54 -91
- package/dist/client/js/storage/adapter.d.ts +130 -0
- package/dist/client/js/storage/adapter.d.ts.map +1 -0
- package/dist/client/js/storage/adapter.js +5 -0
- package/dist/client/js/storage/client.d.ts +72 -0
- package/dist/client/js/storage/client.d.ts.map +1 -0
- package/dist/client/js/storage/client.js +121 -0
- package/dist/client/js/storage/db.d.ts +8 -0
- package/dist/client/js/storage/db.d.ts.map +1 -0
- package/dist/client/js/storage/db.js +35 -0
- package/dist/client/js/storage/fsa.d.ts +51 -0
- package/dist/client/js/storage/fsa.d.ts.map +1 -0
- package/dist/client/js/storage/fsa.js +91 -0
- package/dist/client/js/storage/github.d.ts +62 -0
- package/dist/client/js/storage/github.d.ts.map +1 -0
- package/dist/client/js/storage/github.js +216 -0
- package/dist/client/js/storage/storage.d.ts +32 -0
- package/dist/client/js/storage/storage.d.ts.map +1 -0
- package/dist/client/js/storage/storage.js +68 -0
- package/dist/client/js/storage/workers/frontmatter.d.ts +2 -0
- package/dist/client/js/storage/workers/frontmatter.d.ts.map +1 -0
- package/dist/client/js/storage/workers/frontmatter.js +253 -0
- package/dist/client/js/storage/workers/storage.d.ts +2 -0
- package/dist/client/js/storage/workers/storage.d.ts.map +1 -0
- package/dist/client/js/storage/workers/storage.js +167 -0
- package/dist/client/js/storage/workers/toml-parser.d.ts +2 -0
- package/dist/client/js/storage/workers/toml-parser.d.ts.map +1 -0
- package/dist/client/js/storage/workers/toml-parser.js +75 -0
- package/dist/client/js/storage/workers/yaml-parser.d.ts +2 -0
- package/dist/client/js/storage/workers/yaml-parser.d.ts.map +1 -0
- package/dist/client/js/storage/workers/yaml-parser.js +100 -0
- package/dist/client/js/utils/file-types.d.ts +58 -0
- package/dist/client/js/utils/file-types.d.ts.map +1 -0
- package/{src/client/js/utils/file-types.ts → dist/client/js/utils/file-types.js} +75 -107
- package/dist/client/js/utils/format.d.ts +8 -0
- package/dist/client/js/utils/format.d.ts.map +1 -0
- package/{src/client/js/utils/format.ts → dist/client/js/utils/format.js} +5 -6
- package/dist/client/js/utils/frontmatter.d.ts +12 -0
- package/dist/client/js/utils/frontmatter.d.ts.map +1 -0
- package/dist/client/js/utils/frontmatter.js +29 -0
- package/dist/client/js/utils/schema-utils.d.ts +110 -0
- package/dist/client/js/utils/schema-utils.d.ts.map +1 -0
- package/dist/client/js/utils/schema-utils.js +242 -0
- package/dist/client/js/utils/slug.d.ts +8 -0
- package/dist/client/js/utils/slug.d.ts.map +1 -0
- package/{src/client/js/utils/slug.ts → dist/client/js/utils/slug.js} +6 -7
- package/dist/client/js/utils/sort.d.ts +41 -0
- package/dist/client/js/utils/sort.d.ts.map +1 -0
- package/dist/client/js/utils/sort.js +65 -0
- package/dist/client/js/utils/stable-stringify.d.ts +8 -0
- package/dist/client/js/utils/stable-stringify.d.ts.map +1 -0
- package/dist/client/js/utils/stable-stringify.js +23 -0
- package/dist/client/js/utils/url-utils.d.ts +11 -0
- package/dist/client/js/utils/url-utils.d.ts.map +1 -0
- package/{src/client/js/utils/url-utils.ts → dist/client/js/utils/url-utils.js} +22 -23
- package/dist/client/types/browser-apis.d.ts +39 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +13 -3
- package/.github/workflows/ci.yml +0 -27
- package/.github/workflows/publish.yml +0 -34
- package/.mcp.json +0 -12
- package/.prettierignore +0 -5
- package/.prettierrc.cjs +0 -22
- package/AGENTS.md +0 -183
- package/playground/astro.config.mjs +0 -7
- package/playground/node_modules/.bin/astro +0 -21
- package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js +0 -85
- package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js.map +0 -7
- package/playground/node_modules/.vite/deps/_metadata.json +0 -184
- package/playground/node_modules/.vite/deps/astro___aria-query.js +0 -6776
- package/playground/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
- package/playground/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
- package/playground/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
- package/playground/node_modules/.vite/deps/astro___html-escaper.js +0 -34
- package/playground/node_modules/.vite/deps/astro___html-escaper.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js +0 -0
- package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
- package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js +0 -21
- package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js +0 -223
- package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-FPEUJ7DG.js +0 -27
- package/playground/node_modules/.vite/deps/chunk-FPEUJ7DG.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-MHDZ3SK7.js +0 -1005
- package/playground/node_modules/.vite/deps/chunk-MHDZ3SK7.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-RBDTDTPY.js +0 -204
- package/playground/node_modules/.vite/deps/chunk-RBDTDTPY.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-RJGEXL5C.js +0 -688
- package/playground/node_modules/.vite/deps/chunk-RJGEXL5C.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-YL4MIWGJ.js +0 -5099
- package/playground/node_modules/.vite/deps/chunk-YL4MIWGJ.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZOV3DWEJ.js +0 -4376
- package/playground/node_modules/.vite/deps/chunk-ZOV3DWEJ.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js +0 -23
- package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js +0 -148
- package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js.map +0 -7
- package/playground/node_modules/.vite/deps/package.json +0 -3
- package/playground/node_modules/.vite/deps/smol-toml.js +0 -843
- package/playground/node_modules/.vite/deps/smol-toml.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte.js +0 -55
- package/playground/node_modules/.vite/deps/svelte.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte___clsx.js +0 -9
- package/playground/node_modules/.vite/deps/svelte___clsx.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_animate.js +0 -57
- package/playground/node_modules/.vite/deps/svelte_animate.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_attachments.js +0 -15
- package/playground/node_modules/.vite/deps/svelte_attachments.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_easing.js +0 -67
- package/playground/node_modules/.vite/deps/svelte_easing.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_events.js +0 -11
- package/playground/node_modules/.vite/deps/svelte_events.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal.js +0 -5
- package/playground/node_modules/.vite/deps/svelte_internal.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_client.js +0 -402
- package/playground/node_modules/.vite/deps/svelte_internal_client.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js +0 -10
- package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_legacy.js +0 -35
- package/playground/node_modules/.vite/deps/svelte_legacy.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_motion.js +0 -545
- package/playground/node_modules/.vite/deps/svelte_motion.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_reactivity.js +0 -29
- package/playground/node_modules/.vite/deps/svelte_reactivity.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_reactivity_window.js +0 -127
- package/playground/node_modules/.vite/deps/svelte_reactivity_window.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_store.js +0 -103
- package/playground/node_modules/.vite/deps/svelte_store.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_transition.js +0 -208
- package/playground/node_modules/.vite/deps/svelte_transition.js.map +0 -7
- package/playground/package.json +0 -16
- package/playground/pnpm-lock.yaml +0 -3167
- package/playground/src/content/authors/jane-doe.json +0 -8
- package/playground/src/content/config/build.toml +0 -2
- package/playground/src/content/courses/web-fundamentals.json +0 -29
- package/playground/src/content/docs/advanced.mdx +0 -6
- package/playground/src/content/docs/intro.md +0 -6
- package/playground/src/content/guides/getting-started.mdx +0 -6
- package/playground/src/content/posts/hello-world.md +0 -7
- package/playground/src/content/products/t-shirt.json +0 -16
- package/playground/src/content/recipes/pancakes.mdoc +0 -8
- package/playground/src/content/settings/site.yml +0 -2
- package/playground/src/content.config.ts +0 -198
- package/playground/src/env.d.ts +0 -1
- package/playground/src/pages/index.astro +0 -11
- package/playground/src/pages/nebula.astro +0 -14
- package/pnpm-workspace.yaml +0 -2
- package/scripts/subset-icons.mjs +0 -178
- package/src/astro/index.ts +0 -295
- package/src/client/js/drafts/merge.svelte.ts +0 -121
- package/src/client/js/drafts/ops.svelte.ts +0 -227
- package/src/client/js/drafts/storage.ts +0 -108
- package/src/client/js/drafts/workers/diff.ts +0 -40
- package/src/client/js/editor/editor.svelte.ts +0 -343
- package/src/client/js/editor/languages.ts +0 -98
- package/src/client/js/editor/markdown-shortcuts.ts +0 -261
- package/src/client/js/handlers/admin.ts +0 -246
- package/src/client/js/state/dialogs.svelte.ts +0 -35
- package/src/client/js/state/router.svelte.ts +0 -156
- package/src/client/js/state/state.svelte.ts +0 -334
- package/src/client/js/storage/adapter.ts +0 -102
- package/src/client/js/storage/client.ts +0 -150
- package/src/client/js/storage/db.ts +0 -36
- package/src/client/js/storage/fsa.ts +0 -110
- package/src/client/js/storage/github.ts +0 -297
- package/src/client/js/storage/storage.ts +0 -83
- package/src/client/js/storage/workers/frontmatter.ts +0 -320
- package/src/client/js/storage/workers/storage.ts +0 -177
- package/src/client/js/storage/workers/toml-parser.ts +0 -106
- package/src/client/js/storage/workers/yaml-parser.ts +0 -132
- package/src/client/js/utils/frontmatter.ts +0 -38
- package/src/client/js/utils/schema-utils.ts +0 -295
- package/src/client/js/utils/sort.ts +0 -84
- package/src/client/js/utils/stable-stringify.ts +0 -27
- package/src/types.ts +0 -25
- package/svelte.config.js +0 -4
- package/tests/astro/build.test.ts +0 -63
- package/tests/astro/index.test.ts +0 -689
- package/tests/client/components/Admin.test.ts +0 -446
- package/tests/client/components/BackendPicker.test.ts +0 -239
- package/tests/client/components/DraftChip.test.ts +0 -53
- package/tests/client/components/MetadataForm.test.ts +0 -164
- package/tests/client/components/dialogs/DeleteDraftDialog.test.ts +0 -91
- package/tests/client/components/dialogs/FilenameDialog.test.ts +0 -209
- package/tests/client/components/dialogs/dialog-stubs.ts +0 -19
- package/tests/client/components/editor/EditorPane.test.ts +0 -100
- package/tests/client/components/editor/EditorTabs.test.ts +0 -253
- package/tests/client/components/editor/EditorToolbar.test.ts +0 -252
- package/tests/client/components/editor/fixtures.ts +0 -31
- package/tests/client/components/fields/ArrayField.test.ts +0 -197
- package/tests/client/components/fields/BooleanField.test.ts +0 -206
- package/tests/client/components/fields/DateField.test.ts +0 -210
- package/tests/client/components/fields/EnumField.test.ts +0 -246
- package/tests/client/components/fields/NumberField.test.ts +0 -240
- package/tests/client/components/fields/ObjectField.test.ts +0 -157
- package/tests/client/components/fields/SchemaField.test.ts +0 -190
- package/tests/client/components/fields/StringField.test.ts +0 -223
- package/tests/client/components/sidebar/AdminSidebar.test.ts +0 -285
- package/tests/client/components/sidebar/AdminSidebarSort.test.ts +0 -135
- package/tests/client/components/sidebar/sort-mock.ts +0 -23
- package/tests/client/js/drafts/fixtures.ts +0 -22
- package/tests/client/js/drafts/merge.test.ts +0 -282
- package/tests/client/js/drafts/ops.test.ts +0 -658
- package/tests/client/js/drafts/storage.test.ts +0 -200
- package/tests/client/js/drafts/workers/diff.test.ts +0 -165
- package/tests/client/js/editor/editor.test.ts +0 -616
- package/tests/client/js/editor/link-wrap.test.ts +0 -225
- package/tests/client/js/editor/markdown-shortcuts.test.ts +0 -370
- package/tests/client/js/handlers/admin.test.ts +0 -467
- package/tests/client/js/state/router.test.ts +0 -619
- package/tests/client/js/state/schema.test.ts +0 -266
- package/tests/client/js/state/state.test.ts +0 -328
- package/tests/client/js/storage/adapter.test.ts +0 -115
- package/tests/client/js/storage/client.test.ts +0 -250
- package/tests/client/js/storage/db.test.ts +0 -59
- package/tests/client/js/storage/fsa.test.ts +0 -284
- package/tests/client/js/storage/github.test.ts +0 -349
- package/tests/client/js/storage/mock-port.ts +0 -95
- package/tests/client/js/storage/storage.test.ts +0 -77
- package/tests/client/js/storage/workers/frontmatter.test.ts +0 -479
- package/tests/client/js/storage/workers/storage.test.ts +0 -299
- package/tests/client/js/storage/workers/toml-parser.test.ts +0 -169
- package/tests/client/js/storage/workers/yaml-parser.test.ts +0 -168
- package/tests/client/js/utils/file-types.test.ts +0 -268
- package/tests/client/js/utils/frontmatter.test.ts +0 -87
- package/tests/client/js/utils/schema-utils.test.ts +0 -318
- package/tests/client/js/utils/slug.test.ts +0 -58
- package/tests/client/js/utils/sort.test.ts +0 -276
- package/tests/client/js/utils/stable-stringify.test.ts +0 -68
- package/tests/client/js/utils/url-utils.test.ts +0 -70
- package/tests/e2e/backend-connection.test.ts +0 -301
- package/tests/e2e/draft-lifecycle.test.ts +0 -388
- package/tests/e2e/editing.test.ts +0 -355
- package/tests/e2e/github-adapter.test.ts +0 -330
- package/tests/e2e/helpers/mock-adapter.ts +0 -166
- package/tests/e2e/helpers/test-app.ts +0 -155
- package/tests/e2e/navigation.test.ts +0 -358
- package/tests/e2e/publishing.test.ts +0 -345
- package/tests/e2e/unsaved-changes.test.ts +0 -317
- package/tests/setup.ts +0 -2
- package/tests/stubs/codemirror.ts +0 -197
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -178
- /package/{src → dist}/client/components/BackendPicker.svelte +0 -0
- /package/{src → dist}/client/components/DraftChip.svelte +0 -0
- /package/{src → dist}/client/components/MetadataForm.svelte +0 -0
- /package/{src → dist}/client/components/ThemeToggle.svelte +0 -0
- /package/{src → dist}/client/components/dialogs/DeleteDraftDialog.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorPane.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorTabs.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorToolbar.svelte +0 -0
- /package/{src → dist}/client/components/editor/FormatSelector.svelte +0 -0
- /package/{src → dist}/client/components/editor/Toolbar.svelte +0 -0
- /package/{src → dist}/client/components/fields/ArrayField.svelte +0 -0
- /package/{src → dist}/client/components/fields/ArrayItem.svelte +0 -0
- /package/{src → dist}/client/components/fields/BooleanField.svelte +0 -0
- /package/{src → dist}/client/components/fields/DateField.svelte +0 -0
- /package/{src → dist}/client/components/fields/EnumField.svelte +0 -0
- /package/{src → dist}/client/components/fields/FieldWrapper.svelte +0 -0
- /package/{src → dist}/client/components/fields/NumberField.svelte +0 -0
- /package/{src → dist}/client/components/fields/ObjectField.svelte +0 -0
- /package/{src → dist}/client/components/fields/SchemaField.svelte +0 -0
- /package/{src → dist}/client/components/fields/StringField.svelte +0 -0
- /package/{src → dist}/client/components/sidebar/AdminSidebarSort.svelte +0 -0
- /package/{src → dist}/client/css/a11y.css +0 -0
- /package/{src → dist}/client/css/btn.css +0 -0
- /package/{src → dist}/client/css/dialog.css +0 -0
- /package/{src → dist}/client/css/field-input.css +0 -0
- /package/{src → dist}/client/css/reset.css +0 -0
- /package/{src → dist}/client/css/theme.css +0 -0
- /package/{src/client/index.ts → dist/client/index.js} +0 -0
- /package/{src → dist}/virtual.d.ts +0 -0
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { slugify } from '../../../../src/client/js/utils/slug';
|
|
3
|
-
|
|
4
|
-
describe('slugify', () => {
|
|
5
|
-
it('lowercases the input', () => {
|
|
6
|
-
expect(slugify('Hello World')).toBe('hello-world');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('replaces spaces with hyphens', () => {
|
|
10
|
-
expect(slugify('foo bar baz')).toBe('foo-bar-baz');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('replaces special characters with hyphens', () => {
|
|
14
|
-
expect(slugify('hello! world?')).toBe('hello-world');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('collapses consecutive hyphens into one', () => {
|
|
18
|
-
expect(slugify('foo---bar')).toBe('foo-bar');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('trims leading hyphens', () => {
|
|
22
|
-
expect(slugify('---foo')).toBe('foo');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('trims trailing hyphens', () => {
|
|
26
|
-
expect(slugify('foo---')).toBe('foo');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('handles unicode characters by replacing them with hyphens', () => {
|
|
30
|
-
expect(slugify('café')).toBe('caf');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('handles strings with only special characters', () => {
|
|
34
|
-
expect(slugify('!@#$%')).toBe('');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('returns an empty string for an empty input', () => {
|
|
38
|
-
expect(slugify('')).toBe('');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('leaves an already-slugified string unchanged', () => {
|
|
42
|
-
expect(slugify('already-a-slug')).toBe('already-a-slug');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('handles numeric characters', () => {
|
|
46
|
-
expect(slugify('Post 42')).toBe('post-42');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('handles mixed alphanumeric and special characters', () => {
|
|
50
|
-
expect(slugify('My Post: The (2024) Edition!')).toBe(
|
|
51
|
-
'my-post-the-2024-edition',
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('preserves existing hyphens in the middle of words', () => {
|
|
56
|
-
expect(slugify('well-known')).toBe('well-known');
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
toSortDate,
|
|
4
|
-
createComparator,
|
|
5
|
-
readSortMode,
|
|
6
|
-
writeSortMode,
|
|
7
|
-
SORT_MODES,
|
|
8
|
-
SORT_ORDER,
|
|
9
|
-
} from '../../../../src/client/js/utils/sort';
|
|
10
|
-
import type { SidebarItem } from '../../../../src/client/js/utils/sort';
|
|
11
|
-
|
|
12
|
-
//////////////////////////////
|
|
13
|
-
// localStorage mock helpers
|
|
14
|
-
//////////////////////////////
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Minimal in-memory localStorage mock. The unit test environment runs in Node
|
|
18
|
-
* which has no built-in localStorage, so we stub it globally for the tests
|
|
19
|
-
* that exercise readSortMode / writeSortMode.
|
|
20
|
-
*/
|
|
21
|
-
function makeLocalStorageMock(): Storage {
|
|
22
|
-
let store: Record<string, string> = {};
|
|
23
|
-
return {
|
|
24
|
-
getItem: (key: string) => store[key] ?? null,
|
|
25
|
-
setItem: (key: string, value: string) => {
|
|
26
|
-
store[key] = value;
|
|
27
|
-
},
|
|
28
|
-
removeItem: (key: string) => {
|
|
29
|
-
delete store[key];
|
|
30
|
-
},
|
|
31
|
-
clear: () => {
|
|
32
|
-
store = {};
|
|
33
|
-
},
|
|
34
|
-
get length() {
|
|
35
|
-
return Object.keys(store).length;
|
|
36
|
-
},
|
|
37
|
-
key: (index: number) => Object.keys(store)[index] ?? null,
|
|
38
|
-
} as Storage;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//////////////////////////////
|
|
42
|
-
// toSortDate
|
|
43
|
-
//////////////////////////////
|
|
44
|
-
|
|
45
|
-
describe('toSortDate', () => {
|
|
46
|
-
it('returns a Date unchanged when passed a Date instance', () => {
|
|
47
|
-
const d = new Date('2024-01-15');
|
|
48
|
-
expect(toSortDate(d)).toBe(d);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('parses a valid ISO date string into a Date', () => {
|
|
52
|
-
const result = toSortDate('2024-06-01');
|
|
53
|
-
expect(result).toBeInstanceOf(Date);
|
|
54
|
-
expect(result?.getFullYear()).toBe(2024);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('parses a valid ISO datetime string into a Date', () => {
|
|
58
|
-
const result = toSortDate('2024-06-01T12:00:00Z');
|
|
59
|
-
expect(result).toBeInstanceOf(Date);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('returns a Date (possibly Invalid) for a non-date string — callers handle invalid dates', () => {
|
|
63
|
-
// The function returns new Date(str) for any string; invalid date strings
|
|
64
|
-
// yield an Invalid Date object rather than undefined.
|
|
65
|
-
const result = toSortDate('not-a-date');
|
|
66
|
-
expect(result).toBeInstanceOf(Date);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('returns undefined for null', () => {
|
|
70
|
-
expect(toSortDate(null)).toBeUndefined();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('returns undefined for undefined', () => {
|
|
74
|
-
expect(toSortDate(undefined)).toBeUndefined();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('returns undefined for a number', () => {
|
|
78
|
-
expect(toSortDate(42)).toBeUndefined();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('returns undefined for an object', () => {
|
|
82
|
-
expect(toSortDate({ date: '2024-01-01' })).toBeUndefined();
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
//////////////////////////////
|
|
87
|
-
// createComparator — alpha mode
|
|
88
|
-
//////////////////////////////
|
|
89
|
-
|
|
90
|
-
describe('createComparator — alpha', () => {
|
|
91
|
-
const cmp = createComparator('alpha');
|
|
92
|
-
|
|
93
|
-
it('sorts items lexicographically by label', () => {
|
|
94
|
-
const a: SidebarItem = { label: 'Banana', href: '/b' };
|
|
95
|
-
const b: SidebarItem = { label: 'Apple', href: '/a' };
|
|
96
|
-
expect(cmp(a, b)).toBeGreaterThan(0);
|
|
97
|
-
expect(cmp(b, a)).toBeLessThan(0);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('returns 0 for identical labels', () => {
|
|
101
|
-
const a: SidebarItem = { label: 'Same', href: '/a' };
|
|
102
|
-
const b: SidebarItem = { label: 'Same', href: '/b' };
|
|
103
|
-
expect(cmp(a, b)).toBe(0);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('is case-insensitive', () => {
|
|
107
|
-
const a: SidebarItem = { label: 'apple', href: '/a' };
|
|
108
|
-
const b: SidebarItem = { label: 'Apple', href: '/b' };
|
|
109
|
-
expect(cmp(a, b)).toBe(0);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
//////////////////////////////
|
|
114
|
-
// createComparator — date-asc mode
|
|
115
|
-
//////////////////////////////
|
|
116
|
-
|
|
117
|
-
describe('createComparator — date-asc', () => {
|
|
118
|
-
const cmp = createComparator('date-asc');
|
|
119
|
-
|
|
120
|
-
it('sorts earlier dates before later dates', () => {
|
|
121
|
-
const a: SidebarItem = {
|
|
122
|
-
label: 'A',
|
|
123
|
-
href: '/a',
|
|
124
|
-
date: new Date('2023-01-01'),
|
|
125
|
-
};
|
|
126
|
-
const b: SidebarItem = {
|
|
127
|
-
label: 'B',
|
|
128
|
-
href: '/b',
|
|
129
|
-
date: new Date('2024-01-01'),
|
|
130
|
-
};
|
|
131
|
-
expect(cmp(a, b)).toBeLessThan(0);
|
|
132
|
-
expect(cmp(b, a)).toBeGreaterThan(0);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('returns 0 for equal dates', () => {
|
|
136
|
-
const a: SidebarItem = {
|
|
137
|
-
label: 'A',
|
|
138
|
-
href: '/a',
|
|
139
|
-
date: new Date('2024-01-01'),
|
|
140
|
-
};
|
|
141
|
-
const b: SidebarItem = {
|
|
142
|
-
label: 'B',
|
|
143
|
-
href: '/b',
|
|
144
|
-
date: new Date('2024-01-01'),
|
|
145
|
-
};
|
|
146
|
-
expect(cmp(a, b)).toBe(0);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('sorts items without a date to the top (before items with a date)', () => {
|
|
150
|
-
const nodateItem: SidebarItem = { label: 'A', href: '/a' };
|
|
151
|
-
const datedItem: SidebarItem = {
|
|
152
|
-
label: 'B',
|
|
153
|
-
href: '/b',
|
|
154
|
-
date: new Date('2020-01-01'),
|
|
155
|
-
};
|
|
156
|
-
expect(cmp(nodateItem, datedItem)).toBeLessThan(0);
|
|
157
|
-
expect(cmp(datedItem, nodateItem)).toBeGreaterThan(0);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('returns 0 when both items have no date', () => {
|
|
161
|
-
const a: SidebarItem = { label: 'A', href: '/a' };
|
|
162
|
-
const b: SidebarItem = { label: 'B', href: '/b' };
|
|
163
|
-
expect(cmp(a, b)).toBe(0);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
//////////////////////////////
|
|
168
|
-
// createComparator — date-desc mode
|
|
169
|
-
//////////////////////////////
|
|
170
|
-
|
|
171
|
-
describe('createComparator — date-desc', () => {
|
|
172
|
-
const cmp = createComparator('date-desc');
|
|
173
|
-
|
|
174
|
-
it('sorts later dates before earlier dates', () => {
|
|
175
|
-
const a: SidebarItem = {
|
|
176
|
-
label: 'A',
|
|
177
|
-
href: '/a',
|
|
178
|
-
date: new Date('2024-01-01'),
|
|
179
|
-
};
|
|
180
|
-
const b: SidebarItem = {
|
|
181
|
-
label: 'B',
|
|
182
|
-
href: '/b',
|
|
183
|
-
date: new Date('2023-01-01'),
|
|
184
|
-
};
|
|
185
|
-
expect(cmp(a, b)).toBeLessThan(0);
|
|
186
|
-
expect(cmp(b, a)).toBeGreaterThan(0);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('sorts items without a date to the top', () => {
|
|
190
|
-
const nodateItem: SidebarItem = { label: 'A', href: '/a' };
|
|
191
|
-
const datedItem: SidebarItem = {
|
|
192
|
-
label: 'B',
|
|
193
|
-
href: '/b',
|
|
194
|
-
date: new Date('2020-01-01'),
|
|
195
|
-
};
|
|
196
|
-
expect(cmp(nodateItem, datedItem)).toBeLessThan(0);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
//////////////////////////////
|
|
201
|
-
// readSortMode / writeSortMode
|
|
202
|
-
//////////////////////////////
|
|
203
|
-
|
|
204
|
-
describe('readSortMode / writeSortMode', () => {
|
|
205
|
-
beforeEach(() => {
|
|
206
|
-
// Stub localStorage globally — Node has no built-in localStorage
|
|
207
|
-
vi.stubGlobal('localStorage', makeLocalStorageMock());
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
afterEach(() => {
|
|
211
|
-
vi.unstubAllGlobals();
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it('defaults to "alpha" when no value is stored', () => {
|
|
215
|
-
expect(readSortMode('my-collection')).toBe('alpha');
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('returns the stored "alpha" mode', () => {
|
|
219
|
-
writeSortMode('my-collection', 'alpha');
|
|
220
|
-
expect(readSortMode('my-collection')).toBe('alpha');
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('returns the stored "date-asc" mode', () => {
|
|
224
|
-
writeSortMode('my-collection', 'date-asc');
|
|
225
|
-
expect(readSortMode('my-collection')).toBe('date-asc');
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('returns the stored "date-desc" mode', () => {
|
|
229
|
-
writeSortMode('my-collection', 'date-desc');
|
|
230
|
-
expect(readSortMode('my-collection')).toBe('date-desc');
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('defaults to "alpha" when the stored value is not a valid SortMode', () => {
|
|
234
|
-
localStorage.setItem('cms-sort-my-collection', 'invalid-value');
|
|
235
|
-
expect(readSortMode('my-collection')).toBe('alpha');
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('namespaces storage keys by collection name', () => {
|
|
239
|
-
writeSortMode('posts', 'date-desc');
|
|
240
|
-
writeSortMode('pages', 'date-asc');
|
|
241
|
-
expect(readSortMode('posts')).toBe('date-desc');
|
|
242
|
-
expect(readSortMode('pages')).toBe('date-asc');
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
//////////////////////////////
|
|
247
|
-
// SORT_MODES and SORT_ORDER constants
|
|
248
|
-
//////////////////////////////
|
|
249
|
-
|
|
250
|
-
describe('SORT_MODES constant', () => {
|
|
251
|
-
it('contains an entry for every SortMode', () => {
|
|
252
|
-
expect(SORT_MODES).toHaveProperty('alpha');
|
|
253
|
-
expect(SORT_MODES).toHaveProperty('date-asc');
|
|
254
|
-
expect(SORT_MODES).toHaveProperty('date-desc');
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it('each entry has icon and label strings', () => {
|
|
258
|
-
for (const entry of Object.values(SORT_MODES)) {
|
|
259
|
-
expect(typeof entry.icon).toBe('string');
|
|
260
|
-
expect(typeof entry.label).toBe('string');
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
describe('SORT_ORDER constant', () => {
|
|
266
|
-
it('is an array with exactly 3 entries', () => {
|
|
267
|
-
expect(Array.isArray(SORT_ORDER)).toBe(true);
|
|
268
|
-
expect(SORT_ORDER).toHaveLength(3);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it('contains all three SortMode values', () => {
|
|
272
|
-
expect(SORT_ORDER).toContain('alpha');
|
|
273
|
-
expect(SORT_ORDER).toContain('date-asc');
|
|
274
|
-
expect(SORT_ORDER).toContain('date-desc');
|
|
275
|
-
});
|
|
276
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { stableStringify } from '../../../../src/client/js/utils/stable-stringify';
|
|
3
|
-
|
|
4
|
-
describe('stableStringify', () => {
|
|
5
|
-
it('produces the same output regardless of key insertion order', () => {
|
|
6
|
-
const objA = { z: 1, a: 2, m: 3 };
|
|
7
|
-
const objB = { a: 2, m: 3, z: 1 };
|
|
8
|
-
expect(stableStringify(objA)).toBe(stableStringify(objB));
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('sorts keys alphabetically at the top level', () => {
|
|
12
|
-
const obj = { z: 1, a: 2, m: 3 };
|
|
13
|
-
expect(stableStringify(obj)).toBe('{"a":2,"m":3,"z":1}');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('sorts keys recursively in nested objects', () => {
|
|
17
|
-
const obj = { b: { y: 1, x: 2 }, a: { q: 3, p: 4 } };
|
|
18
|
-
expect(stableStringify(obj)).toBe('{"a":{"p":4,"q":3},"b":{"x":2,"y":1}}');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('preserves array element order (arrays are not sorted)', () => {
|
|
22
|
-
const obj = { items: [3, 1, 2] };
|
|
23
|
-
expect(stableStringify(obj)).toBe('{"items":[3,1,2]}');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('handles null values correctly', () => {
|
|
27
|
-
const obj = { a: null, b: 'text' };
|
|
28
|
-
expect(stableStringify(obj)).toBe('{"a":null,"b":"text"}');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('handles a top-level null', () => {
|
|
32
|
-
expect(stableStringify(null)).toBe('null');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('serializes an empty object', () => {
|
|
36
|
-
expect(stableStringify({})).toBe('{}');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('serializes an empty array', () => {
|
|
40
|
-
expect(stableStringify([])).toBe('[]');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('serializes primitive string values', () => {
|
|
44
|
-
expect(stableStringify('hello')).toBe('"hello"');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('serializes primitive number values', () => {
|
|
48
|
-
expect(stableStringify(42)).toBe('42');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('serializes boolean values', () => {
|
|
52
|
-
expect(stableStringify(true)).toBe('true');
|
|
53
|
-
expect(stableStringify(false)).toBe('false');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('handles arrays containing objects with sorted keys', () => {
|
|
57
|
-
const arr = [
|
|
58
|
-
{ b: 2, a: 1 },
|
|
59
|
-
{ d: 4, c: 3 },
|
|
60
|
-
];
|
|
61
|
-
expect(stableStringify(arr)).toBe('[{"a":1,"b":2},{"c":3,"d":4}]');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('is deterministic across multiple calls', () => {
|
|
65
|
-
const obj = { x: { q: 1, p: 2 }, a: [3, 2, 1] };
|
|
66
|
-
expect(stableStringify(obj)).toBe(stableStringify(obj));
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { isURL } from '../../../../src/client/js/utils/url-utils';
|
|
3
|
-
|
|
4
|
-
describe('isURL', () => {
|
|
5
|
-
// Valid absolute URLs
|
|
6
|
-
it('returns true for an https URL', () => {
|
|
7
|
-
expect(isURL('https://example.com')).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns true for an http URL', () => {
|
|
11
|
-
expect(isURL('http://example.com')).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('returns true for an https URL with a path', () => {
|
|
15
|
-
expect(isURL('https://example.com/some/path')).toBe(true);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('returns true for an https URL with query params', () => {
|
|
19
|
-
expect(isURL('https://example.com/search?q=test&page=2')).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('returns true for a mailto: URL', () => {
|
|
23
|
-
expect(isURL('mailto:user@example.com')).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Absolute paths
|
|
27
|
-
it('returns true for an absolute path starting with /', () => {
|
|
28
|
-
expect(isURL('/some/path')).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('returns true for the root path /', () => {
|
|
32
|
-
expect(isURL('/')).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Non-URLs
|
|
36
|
-
it('returns false for plain text', () => {
|
|
37
|
-
expect(isURL('hello world')).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('returns false for a relative path without leading slash', () => {
|
|
41
|
-
expect(isURL('some/relative/path')).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('returns false for a word that looks like a domain but has no scheme', () => {
|
|
45
|
-
expect(isURL('example.com')).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('returns true for a protocol-relative URL — it starts with / so the absolute-path branch accepts it', () => {
|
|
49
|
-
// //example.com/path starts with /, so new URL('//example.com/path', 'https://a.com')
|
|
50
|
-
// resolves successfully. The function accepts absolute paths without requiring a scheme.
|
|
51
|
-
expect(isURL('//example.com/path')).toBe(true);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Edge cases
|
|
55
|
-
it('returns false for an empty string', () => {
|
|
56
|
-
expect(isURL('')).toBe(false);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('returns false for a whitespace-only string', () => {
|
|
60
|
-
expect(isURL(' ')).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('trims whitespace before validation — valid URL with surrounding spaces', () => {
|
|
64
|
-
expect(isURL(' https://example.com ')).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('trims whitespace before validation — plain text with surrounding spaces', () => {
|
|
68
|
-
expect(isURL(' hello ')).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
});
|