@yolean/evidence 0.0.0-stage → 40.3.0

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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/cli.js +436 -0
  3. package/package.json +66 -3
  4. package/template/README.md +11 -0
  5. package/template/postcss.config.cjs +15 -0
  6. package/template/src/app.css +327 -0
  7. package/template/src/app.html +96 -0
  8. package/template/src/fix-tprotocol-service-worker.js +36 -0
  9. package/template/src/global.d.ts +1 -0
  10. package/template/src/hooks.client.js +19 -0
  11. package/template/src/hooks.server.js +41 -0
  12. package/template/src/pages/+error.svelte +57 -0
  13. package/template/src/pages/+layout.js +220 -0
  14. package/template/src/pages/+layout.svelte +10 -0
  15. package/template/src/pages/+page.md +16 -0
  16. package/template/src/pages/api/[...route]/evidencemeta.json/+server.js +48 -0
  17. package/template/src/pages/api/[route_hash]/[additional_hash]/all-queries.json/+server.js +10 -0
  18. package/template/src/pages/api/customFormattingSettings.json/+server.js +82 -0
  19. package/template/src/pages/api/customFormattingSettings.json/GET.json/+server.js +6 -0
  20. package/template/src/pages/api/pagesManifest.json/+server.js +92 -0
  21. package/template/src/pages/api/pagesManifest.json/buildPageManifest.spec.js +274 -0
  22. package/template/src/pages/api/prerendered_queries/[query_hash].arrow/+server.js +10 -0
  23. package/template/src/pages/api/settings.json/+server.js +107 -0
  24. package/template/src/pages/explore/+layout.js +5 -0
  25. package/template/src/pages/explore/console/+page.svelte +5 -0
  26. package/template/src/pages/explore/schema/+page.svelte +13 -0
  27. package/template/src/pages/fix-tprotocol-service-worker.js/+server.js +20 -0
  28. package/template/src/pages/manifest.webmanifest/+server.js +21 -0
  29. package/template/src/pages/settings/+layout.server.js +1 -0
  30. package/template/src/pages/settings/+page.js +25 -0
  31. package/template/src/pages/settings/+page.server.js +110 -0
  32. package/template/src/pages/settings/+page.svelte +111 -0
  33. package/template/static/apple-touch-icon.png +0 -0
  34. package/template/static/favicon.ico +0 -0
  35. package/template/static/icon-192.png +0 -0
  36. package/template/static/icon-512.png +0 -0
  37. package/template/static/icon.svg +6 -0
  38. package/template/svelte.config.js +106 -0
  39. package/template/tailwind.config.cjs +48 -0
  40. package/template/vite.config.js +99 -0
  41. package/README.md +0 -3
@@ -0,0 +1,111 @@
1
+ <script>
2
+ // @ts-check
3
+
4
+ /** @type {import("./$types").PageData} */
5
+ export let data;
6
+ let { settings, customFormattingSettings, sources, plugins } = data;
7
+ $: ({ settings, customFormattingSettings, sources, plugins } = data);
8
+
9
+ import { dev } from '$app/environment';
10
+ import {
11
+ DeploySettingsPanel,
12
+ FormattingSettingsPanel,
13
+ TelemetrySettingsPanel,
14
+ SourceConfig
15
+ } from '@evidence-dev/core-components';
16
+ </script>
17
+
18
+ {#if dev}
19
+ <div
20
+ class="fixed top-12 left-0 right-0 bg-base-100 z-40 py-6 border-b border-base-200 bg-base-100/90 backdrop-blur"
21
+ >
22
+ <div class="max-w-7xl px-6 sm:px-8 md:px-12 mx-auto">
23
+ <a href="/" class="block text-sm text-base-content-muted mb-2"> &larr; Home </a>
24
+ <h1 class="text-xl text-base-content font-bold">Project Settings</h1>
25
+ </div>
26
+ </div>
27
+
28
+ <div class="flex pt-28">
29
+ <div class="w-full relative flex overflow-x-hidden">
30
+ <div class="fixed w-60 top-48 hidden lg:block">
31
+ <div class="flex flex-col gap-4 text-sm text-base-content-muted">
32
+ <a href="#sources" class="hover:text-base-content transition-colors">Sources</a>
33
+ <a href="#deployment" class="hover:text-base-content transition-colors">Deployment</a>
34
+ <a href="#formatting" class="hover:text-base-content transition-colors"
35
+ >Value Formatting</a
36
+ >
37
+ <a href="#telemetry" class="hover:text-base-content transition-colors">Telemetry</a>
38
+ </div>
39
+ </div>
40
+ <div class="flex flex-col lg:ml-60 lg:px-8 gap-12 w-full overflow-x-auto">
41
+ <section id="sources" class="scroll-mt-48">
42
+ <div class="mb-6">
43
+ <h2 class="text-2xl text-base-content font-semibold mb-4 text-pretty">Sources</h2>
44
+ <p class="text-base-content text-base mb-2">
45
+ Sources connect your Evidence project to databases, local files, and APIs. Each source
46
+ creates a directory in your project under <code class="markdown">/sources</code> where
47
+ you can add queries.
48
+ <a
49
+ href="https://docs.evidence.dev/core-concepts/data-sources/"
50
+ target="_blank"
51
+ class="markdown"
52
+ >
53
+ Learn more about sources.
54
+ </a>
55
+ </p>
56
+ </div>
57
+ <SourceConfig availableSourcePlugins={plugins} {sources} />
58
+ </section>
59
+ <section id="deployment" class="scroll-mt-[9.5rem] border-t border-base-300 pt-8">
60
+ <div class="mb-6">
61
+ <h2 class="text-2xl text-base-content font-semibold mb-4">Deployment</h2>
62
+ <p class="text-base-content text-base mb-2">
63
+ Evidence projects can be deployed to a variety of cloud environments.
64
+ <a
65
+ href="https://docs.evidence.dev/deployment/overview/"
66
+ target="_blank"
67
+ class="markdown">Learn more about deployment.</a
68
+ >
69
+ </p>
70
+ </div>
71
+ <DeploySettingsPanel {settings} {sources} />
72
+ </section>
73
+ <section id="formatting" class="scroll-mt-[9.5rem] border-t border-base-300 pt-8">
74
+ <div class="mb-6">
75
+ <h2 class="text-2xl text-base-content font-semibold mb-4">Value Formatting</h2>
76
+ <p class="text-base-content text-base mb-2">
77
+ Evidence supports built-in formats and Excel-style formats. You can apply these
78
+ formats using component props or SQL format tags.
79
+ <a
80
+ href="https://docs.evidence.dev/core-concepts/formatting/"
81
+ target="_blank"
82
+ class="markdown"
83
+ >
84
+ Learn more about formatting.
85
+ </a>
86
+ </p>
87
+ </div>
88
+ <FormattingSettingsPanel {customFormattingSettings} />
89
+ </section>
90
+ <section id="telemetry" class="scroll-mt-[9.5rem] border-t border-base-300 pt-8">
91
+ <div class="mb-6">
92
+ <h2 class="text-2xl text-base-content font-semibold mb-4">Telemetry</h2>
93
+ <p class="text-base-content text-base mb-2">
94
+ The Evidence CLI collects anonymous usage data to help us understand how often the
95
+ tool is being used. <a
96
+ href="https://github.com/evidence-dev/evidence/tree/next/packages/lib/telemetry"
97
+ target="_blank"
98
+ class="markdown"
99
+ >
100
+ View telemetry source code.
101
+ </a>
102
+ </p>
103
+ </div>
104
+ <TelemetrySettingsPanel {settings} />
105
+ </section>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ {:else}
110
+ <p>Settings are only available in development mode.</p>
111
+ {/if}
Binary file
Binary file
Binary file
@@ -0,0 +1,6 @@
1
+ <svg width="1080" height="1080" viewBox="0 0 1080 1080" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="1080" height="1080" rx="540" fill="black"/>
3
+ <path d="M292 356.248C386.446 356.248 461.173 366.53 539.834 324.682C618.494 282.835 694.999 293.116 787.667 293.116L787.667 401.342C694.999 401.342 618.063 391.286 539.834 432.908C461.604 474.53 386.446 464.474 292 464.474L292 356.248Z" fill="white"/>
4
+ <path d="M787.668 723.42C693.222 723.42 618.495 713.139 539.835 754.986C461.175 796.834 384.669 786.552 292.001 786.552V678.326C384.669 678.326 461.606 688.382 539.835 646.76C618.064 605.138 693.222 615.194 787.668 615.194V723.42Z" fill="white"/>
5
+ <path d="M683.317 453.141C633.317 454.167 587.137 460.44 539.835 485.608C474.653 520.288 410.368 519.09 337.133 517.726C322.474 517.453 307.456 517.174 292.001 517.174V625.4C307.642 625.4 322.822 625.693 337.629 625.978C410.556 627.385 474.451 628.618 539.835 593.834C587.359 568.551 633.448 562.296 683.317 561.306V453.141Z" fill="white"/>
6
+ </svg>
@@ -0,0 +1,106 @@
1
+ import evidencePreprocess from '@evidence-dev/preprocess';
2
+ import preprocess from 'svelte-preprocess';
3
+ import adapter from '@sveltejs/adapter-static';
4
+ import { addBasePathToHrefAndSrc, injectComponents } from '@evidence-dev/sdk/build/svelte';
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { getEvidenceConfig } from '@evidence-dev/sdk/config';
8
+ const evidenceConfig = getEvidenceConfig();
9
+ /**
10
+ * @param {Object} a
11
+ * @param {Object} b
12
+ * @returns {Object}
13
+ */
14
+ const deepMerge = (a, b) => {
15
+ for (const key in b) {
16
+ if (typeof b[key] === 'object' && !Array.isArray(b[key])) {
17
+ if (!a[key]) a[key] = {};
18
+ deepMerge(a[key], b[key]);
19
+ } else {
20
+ Object.assign(a, { [key]: b[key] });
21
+ }
22
+ }
23
+ return a;
24
+ };
25
+
26
+ /**
27
+ * Handles errors generated in the Svelte Vite plugin. Temporary approach until this plugin allows errors to be passed through to the browser
28
+ * @param {{ message: string }} warning - The warning object from the Svelte Vite plugin.
29
+ * @throws {Error}
30
+ */
31
+ function errorHandler(warning) {
32
+ if (warning.message.includes('defined') || warning.message.includes('Empty Block')) {
33
+ throw new Error(warning.message, { cause: warning });
34
+ }
35
+ }
36
+
37
+ /** @type {import('@sveltejs/kit').Config} */
38
+ const config = {
39
+ extensions: ['.svelte', '.md'],
40
+ preprocess: [
41
+ ...evidencePreprocess(true),
42
+ injectComponents(),
43
+ preprocess({
44
+ postcss: true,
45
+ // the template has no tsconfig.json for svelte-preprocess to find
46
+ typescript: { compilerOptions: { verbatimModuleSyntax: true } }
47
+ }),
48
+ addBasePathToHrefAndSrc
49
+ ],
50
+ onwarn: errorHandler,
51
+ kit: {
52
+ adapter: adapter({
53
+ pages: process.env.EVIDENCE_BUILD_DIR ?? './build',
54
+ strict: false
55
+ }),
56
+ files: {
57
+ routes: 'src/pages',
58
+ lib: 'src/components'
59
+ },
60
+ paths: {
61
+ base: evidenceConfig.deployment.basePath,
62
+ relative: false
63
+ },
64
+ serviceWorker: {
65
+ register: false
66
+ }
67
+ }
68
+ };
69
+
70
+ async function loadUserConfiguration() {
71
+ if (!process.cwd().includes('.evidence')) return;
72
+ const rootDir = process.cwd().split('.evidence')[0];
73
+ const rootDirContents = fs.readdirSync(rootDir);
74
+
75
+ if (!rootDirContents.includes('svelte.config.js')) return;
76
+
77
+ const configFileLocation = path.join(rootDir, 'svelte.config.js');
78
+ const configURL = new URL(`file:///${configFileLocation}`).href;
79
+ /** @type {import("@sveltejs/kit").Config} */
80
+ const userConfig = await import(configURL).then((r) => r.default);
81
+
82
+ if ('preprocess' in userConfig) {
83
+ if ('preprocess' in config) {
84
+ config.preprocess.push(...userConfig.preprocess);
85
+ } else {
86
+ // This case shouldn't ever be reached.
87
+ config.preprocess = userConfig.preprocess;
88
+ }
89
+ delete userConfig.preprocess;
90
+ }
91
+ if ('extensions' in userConfig) {
92
+ console.warn('Configuring extensions is disabled for Evidence projects.');
93
+ delete userConfig.extensions;
94
+ }
95
+ if ('kit' in userConfig && 'files' in userConfig.kit) {
96
+ console.warn('Configuring file locations is disabled for Evidence projects.');
97
+ delete userConfig.kit.files;
98
+ }
99
+
100
+ deepMerge(config, userConfig);
101
+ console.log('Custom svelte.config.js applied');
102
+ }
103
+
104
+ await loadUserConfiguration();
105
+
106
+ export default config;
@@ -0,0 +1,48 @@
1
+ const evidenceTailwind = require('@evidence-dev/tailwind/config').config;
2
+ const evidenceConfig = require('@evidence-dev/sdk/config').getEvidenceConfig();
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ let presets = [evidenceTailwind];
7
+
8
+ const altConfigFilenames = ['tailwind.config.js', 'tailwind.config.cjs'];
9
+ const altConfigFilepaths = altConfigFilenames.map((filename) => path.join('..', '..', filename));
10
+ // Use find so that we can stop iteration
11
+ altConfigFilepaths.find((file) => {
12
+ if (fs.statSync(file, { throwIfNoEntry: false })) {
13
+ presets.push(require(file));
14
+ return true;
15
+ }
16
+ return false;
17
+ });
18
+
19
+ /** @type {import("tailwindcss").Config} */
20
+ const config = {
21
+ content: {
22
+ relative: true,
23
+ get files() {
24
+ const pluginConfig = evidenceConfig.plugins;
25
+ const components = pluginConfig.components;
26
+ const componentPaths = Object.keys(components)
27
+ .map((pluginName) => [
28
+ `./node_modules/${pluginName}/dist/**/*.{html,js,svelte,ts,md}`,
29
+ `../../node_modules/${pluginName}/dist/**/*.{html,js,svelte,ts,md}`
30
+ ])
31
+ .flat();
32
+
33
+ return [
34
+ './src/**/*.{html,js,svelte,ts,md}', // This is used for everything in base evidence template
35
+ ...componentPaths
36
+ ];
37
+ }
38
+ },
39
+ theme: {
40
+ extend: {}
41
+ },
42
+
43
+ presets: presets,
44
+
45
+ plugins: []
46
+ };
47
+
48
+ module.exports = config;
@@ -0,0 +1,99 @@
1
+ import { sveltekit } from "@sveltejs/kit/vite"
2
+ import { createLogger } from 'vite';
3
+ import { sourceQueryHmr, configVirtual, queryDirectoryHmr } from '@evidence-dev/sdk/build/vite';
4
+ import { isDebug } from '@evidence-dev/sdk/utils';
5
+ import { log } from "@evidence-dev/sdk/logger";
6
+ import { evidenceThemes } from '@evidence-dev/tailwind/vite-plugin';
7
+
8
+
9
+ process.removeAllListeners('warning');
10
+ process.on('warning', (warning) => {
11
+ if (warning.name === 'ExperimentalWarning' &&
12
+ warning.message.includes('CommonJS module') &&
13
+ warning.message.includes('ES Module')) {
14
+ return;
15
+ }
16
+ console.warn(warning);
17
+ });
18
+
19
+
20
+ const logger = createLogger();
21
+
22
+ const strictFs = (process.env.NODE_ENV === 'development') ? false : true;
23
+ /** @type {import('vite').UserConfig} */
24
+ const config =
25
+ {
26
+ plugins: [sveltekit(), configVirtual(), queryDirectoryHmr, sourceQueryHmr(), evidenceThemes()],
27
+ optimizeDeps: {
28
+ include: ['echarts-stat', 'echarts', 'blueimp-md5', 'nanoid', '@uwdata/mosaic-sql',
29
+ // We need these to prevent HMR from doing a full page reload
30
+ ...(process.env.EVIDENCE_DISABLE_INCLUDE ? [] : [
31
+ '@evidence-dev/core-components',
32
+ // Evidence packages injected into process-queries
33
+ '@evidence-dev/component-utilities/stores','@evidence-dev/component-utilities/formatting','@evidence-dev/component-utilities/globalContexts','@evidence-dev/sdk/utils/svelte','@evidence-dev/component-utilities/profile','@evidence-dev/sdk/usql','@evidence-dev/component-utilities/buildQuery',
34
+ 'debounce',
35
+ '@duckdb/duckdb-wasm',
36
+ 'apache-arrow'
37
+ ])
38
+
39
+ ],
40
+ exclude: ['svelte-icons', '@evidence-dev/universal-sql', '$evidence/config', '$evidence/themes']
41
+ },
42
+ ssr: {
43
+ external: ['@evidence-dev/telemetry', 'blueimp-md5', 'nanoid', '@uwdata/mosaic-sql', '@evidence-dev/sdk/plugins']
44
+ },
45
+ server: {
46
+ fs: {
47
+ strict: strictFs // allow template to get dependencies outside the .evidence folder
48
+ },
49
+ hmr: {
50
+ overlay: false
51
+ }
52
+ },
53
+ build: {
54
+ // 🚩 Triple check this
55
+ minify: isDebug() ? false : true,
56
+ target: isDebug() ? 'esnext' : undefined,
57
+ rollupOptions: {
58
+ external: [/^@evidence-dev\/tailwind\/fonts\//],
59
+ onwarn(warning, warn) {
60
+ if (warning.code === 'EVAL') return;
61
+ warn(warning);
62
+ }
63
+ }
64
+ },
65
+ customLogger: logger
66
+ }
67
+
68
+ // Suppress errors when building in non-debug mode
69
+ if (!isDebug() && process.env.EVIDENCE_IS_BUILDING === 'true') {
70
+ config.logLevel = 'silent';
71
+ logger.error = (msg) => log.error(msg);
72
+ logger.info = () => {};
73
+ logger.warn = () => {};
74
+ logger.warnOnce = () => {};
75
+ } else {
76
+ const loggerWarn = logger.warn;
77
+ const loggerOnce = logger.warnOnce
78
+
79
+ /**
80
+ * @see https://github.com/evidence-dev/evidence/issues/1876
81
+ * Ignore the duckdb-wasm sourcemap warning
82
+ */
83
+ logger.warnOnce = (m, o) => {
84
+ if (m.match(/Sourcemap for ".+\/node_modules\/@duckdb\/duckdb-wasm\/dist\/duckdb-browser-eh\.worker\.js" points to missing source files/)) return;
85
+ loggerOnce(m, o)
86
+ }
87
+
88
+ logger.warn = (msg, options) => {
89
+ // ignore fs/promises warning, used in +layout.js behind if (!browser) check
90
+ if (msg.includes('Module "fs/promises" has been externalized for browser compatibility')) return;
91
+
92
+ // ignore eval warning, used in duckdb-wasm
93
+ if (msg.includes('Use of eval in') && msg.includes('is strongly discouraged as it poses security risks and may cause issues with minification.')) return;
94
+
95
+ loggerWarn(msg, options);
96
+ };
97
+ }
98
+
99
+ export default config
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.