opentwig 1.0.7 → 1.1.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.
Files changed (62) hide show
  1. package/AGENTS.md +172 -0
  2. package/API.md +582 -0
  3. package/CODE_OF_CONDUCT.md +91 -0
  4. package/CONTRIBUTING.md +312 -0
  5. package/README.md +164 -7
  6. package/SECURITY.md +56 -0
  7. package/THEME_DEVELOPMENT.md +388 -0
  8. package/package.json +19 -4
  9. package/src/constants.js +14 -2
  10. package/src/index.js +14 -2
  11. package/src/live-ui/editor.js +174 -0
  12. package/src/live-ui/preview.js +77 -0
  13. package/src/live-ui/sidebar.js +525 -0
  14. package/src/utils/escapeHTML.js +10 -0
  15. package/src/utils/favicon.js +20 -0
  16. package/src/utils/generateOGImage.js +51 -10
  17. package/src/utils/loadConfig.js +3 -1
  18. package/src/utils/parseArgs.js +33 -2
  19. package/src/utils/readImageAsBase64.js +16 -4
  20. package/src/utils/setupWatcher.js +69 -0
  21. package/src/utils/showHelp.js +15 -2
  22. package/src/utils/startLiveServer.js +221 -0
  23. package/src/utils/websocketServer.js +53 -0
  24. package/theme/dark/style.css +1 -0
  25. package/theme/default/index.js +12 -8
  26. package/validateConfig.js +59 -0
  27. package/vitest.config.js +20 -0
  28. package/website/README.md +42 -0
  29. package/website/components.json +16 -0
  30. package/website/eslint.config.js +36 -0
  31. package/website/package-lock.json +4136 -0
  32. package/website/package.json +41 -0
  33. package/website/shadcn-svelte.md +118 -0
  34. package/website/src/app.d.ts +13 -0
  35. package/website/src/lib/components/ui/badge/badge.svelte +50 -0
  36. package/website/src/lib/components/ui/badge/index.ts +2 -0
  37. package/website/src/lib/components/ui/button/button.svelte +82 -0
  38. package/website/src/lib/components/ui/button/index.ts +17 -0
  39. package/website/src/lib/components/ui/card/card-action.svelte +20 -0
  40. package/website/src/lib/components/ui/card/card-content.svelte +15 -0
  41. package/website/src/lib/components/ui/card/card-description.svelte +20 -0
  42. package/website/src/lib/components/ui/card/card-footer.svelte +20 -0
  43. package/website/src/lib/components/ui/card/card-header.svelte +23 -0
  44. package/website/src/lib/components/ui/card/card-title.svelte +20 -0
  45. package/website/src/lib/components/ui/card/card.svelte +23 -0
  46. package/website/src/lib/components/ui/card/index.ts +25 -0
  47. package/website/src/lib/components/ui/separator/index.ts +7 -0
  48. package/website/src/lib/components/ui/separator/separator.svelte +21 -0
  49. package/website/src/lib/components/ui/tooltip/index.ts +19 -0
  50. package/website/src/lib/components/ui/tooltip/tooltip-content.svelte +52 -0
  51. package/website/src/lib/components/ui/tooltip/tooltip-portal.svelte +7 -0
  52. package/website/src/lib/components/ui/tooltip/tooltip-provider.svelte +7 -0
  53. package/website/src/lib/components/ui/tooltip/tooltip-trigger.svelte +7 -0
  54. package/website/src/lib/components/ui/tooltip/tooltip.svelte +7 -0
  55. package/website/src/lib/index.ts +1 -0
  56. package/website/src/lib/utils.ts +13 -0
  57. package/website/src/routes/+layout.svelte +23 -0
  58. package/website/src/routes/+page.server.ts +82 -0
  59. package/website/src/routes/+page.svelte +892 -0
  60. package/website/static/robots.txt +3 -0
  61. package/website/svelte.config.js +31 -0
  62. package/website/vite.config.ts +5 -0
@@ -0,0 +1,59 @@
1
+ const fs = require('fs');
2
+ const CONSTANTS = require('./src/constants');
3
+
4
+ function validateConfig(config) {
5
+ const errors = [];
6
+
7
+ // Required fields
8
+ CONSTANTS.REQUIRED_FIELDS.forEach(field => {
9
+ if (!config[field] || typeof config[field] !== 'string') {
10
+ errors.push(`The "${field}" field is required and must be a string.`);
11
+ }
12
+ });
13
+
14
+ // Optional fields
15
+ if (config.theme && !CONSTANTS.SUPPORTED_THEMES.includes(config.theme)) {
16
+ errors.push(
17
+ `Invalid theme "${config.theme}". Supported themes: ${CONSTANTS.SUPPORTED_THEMES.join(', ')}.`
18
+ );
19
+ }
20
+
21
+ if (config.links && !Array.isArray(config.links)) {
22
+ errors.push('The "links" field must be an array if provided.');
23
+ }
24
+
25
+ if (config.footerLinks && !Array.isArray(config.footerLinks)) {
26
+ errors.push('The "footerLinks" field must be an array if provided.');
27
+ }
28
+
29
+ if (config.share && typeof config.share !== 'object') {
30
+ errors.push('The "share" field must be an object if provided.');
31
+ }
32
+
33
+ return errors;
34
+ }
35
+
36
+ function main() {
37
+ try {
38
+ const raw = fs.readFileSync(CONSTANTS.CONFIG_FILE, 'utf-8');
39
+ const config = JSON.parse(raw);
40
+ const errors = validateConfig(config);
41
+
42
+ if (errors.length > 0) {
43
+ console.error(`${CONSTANTS.MESSAGES.ERROR_PREFIX} Validation errors in config.json:`);
44
+ errors.forEach(e => console.error('- ' + e));
45
+ process.exit(1);
46
+ } else {
47
+ console.log(`${CONSTANTS.MESSAGES.SUCCESS_PREFIX} config.json is valid!`);
48
+ }
49
+ } catch (err) {
50
+ console.error(`${CONSTANTS.MESSAGES.ERROR_PREFIX} Failed to read or validate config.json:`, err.message);
51
+ process.exit(1);
52
+ }
53
+ }
54
+
55
+ if (require.main === module) {
56
+ main();
57
+ }
58
+
59
+ module.exports = main;
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ include: ['tests/**/*.test.js'],
8
+ coverage: {
9
+ provider: 'v8',
10
+ reporter: ['text', 'json', 'html'],
11
+ exclude: [
12
+ 'node_modules/',
13
+ 'tests/',
14
+ 'website/',
15
+ 'theme/',
16
+ 'dist/'
17
+ ]
18
+ }
19
+ }
20
+ });
@@ -0,0 +1,42 @@
1
+ # sv
2
+
3
+ Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
4
+
5
+ ## Creating a project
6
+
7
+ If you're seeing this, you've probably already done this step. Congrats!
8
+
9
+ ```sh
10
+ # create a new project
11
+ npx sv create my-app
12
+ ```
13
+
14
+ To recreate this project with the same configuration:
15
+
16
+ ```sh
17
+ # recreate this project
18
+ npx sv create --template minimal --types ts --add eslint tailwindcss="plugins:typography" sveltekit-adapter="adapter:static" --install npm website
19
+ ```
20
+
21
+ ## Developing
22
+
23
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
24
+
25
+ ```sh
26
+ npm run dev
27
+
28
+ # or start the server and open the app in a new browser tab
29
+ npm run dev -- --open
30
+ ```
31
+
32
+ ## Building
33
+
34
+ To create a production version of your app:
35
+
36
+ ```sh
37
+ npm run build
38
+ ```
39
+
40
+ You can preview the production build with `npm run preview`.
41
+
42
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://shadcn-svelte.com/schema.json",
3
+ "tailwind": {
4
+ "css": "src/routes/layout.css",
5
+ "baseColor": "slate"
6
+ },
7
+ "aliases": {
8
+ "components": "$lib/components",
9
+ "utils": "$lib/utils",
10
+ "ui": "$lib/components/ui",
11
+ "hooks": "$lib/hooks",
12
+ "lib": "$lib"
13
+ },
14
+ "typescript": true,
15
+ "registry": "https://shadcn-svelte.com/registry"
16
+ }
@@ -0,0 +1,36 @@
1
+ import path from 'node:path';
2
+ import { includeIgnoreFile } from '@eslint/compat';
3
+ import js from '@eslint/js';
4
+ import svelte from 'eslint-plugin-svelte';
5
+ import { defineConfig } from 'eslint/config';
6
+ import globals from 'globals';
7
+ import ts from 'typescript-eslint';
8
+ import svelteConfig from './svelte.config.js';
9
+
10
+ const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');
11
+
12
+ export default defineConfig(
13
+ includeIgnoreFile(gitignorePath),
14
+ js.configs.recommended,
15
+ ...ts.configs.recommended,
16
+ ...svelte.configs.recommended,
17
+ {
18
+ languageOptions: { globals: { ...globals.browser, ...globals.node } },
19
+ rules: {
20
+ // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
21
+ // see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
22
+ "no-undef": 'off'
23
+ }
24
+ },
25
+ {
26
+ files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
27
+ languageOptions: {
28
+ parserOptions: {
29
+ projectService: true,
30
+ extraFileExtensions: ['.svelte'],
31
+ parser: ts.parser,
32
+ svelteConfig
33
+ }
34
+ }
35
+ }
36
+ );