zone5 0.0.0 → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +258 -0
- package/dist/cli/index.js +33 -0
- package/dist/cli/index2.js +238 -0
- package/dist/cli/index3.js +53 -0
- package/dist/cli/templates/.zone5.toml +4 -0
- package/dist/cli/templates/app.css +3 -0
- package/dist/cli/templates/layout.svelte +15 -0
- package/dist/cli/templates/layout.ts +1 -0
- package/dist/components/Zone5.svelte +153 -0
- package/dist/components/Zone5.svelte.d.ts +12 -0
- package/dist/components/Zone5Img.svelte +103 -0
- package/dist/components/Zone5Img.svelte.d.ts +10 -0
- package/dist/components/Zone5Lightbox.svelte +131 -0
- package/dist/components/Zone5Lightbox.svelte.d.ts +12 -0
- package/dist/components/Zone5Provider.svelte +68 -0
- package/dist/components/Zone5Provider.svelte.d.ts +9 -0
- package/dist/components/atoms/Button.svelte +40 -0
- package/dist/components/atoms/Button.svelte.d.ts +13 -0
- package/dist/components/atoms/CloseButton.svelte +18 -0
- package/dist/components/atoms/CloseButton.svelte.d.ts +9 -0
- package/dist/components/atoms/NextButton.svelte +19 -0
- package/dist/components/atoms/NextButton.svelte.d.ts +10 -0
- package/dist/components/atoms/PrevButton.svelte +19 -0
- package/dist/components/atoms/PrevButton.svelte.d.ts +10 -0
- package/dist/components/atoms/index.d.ts +4 -0
- package/dist/components/atoms/index.js +5 -0
- package/dist/components/constants.d.ts +17 -0
- package/dist/components/constants.js +17 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +7 -0
- package/dist/components/portal.d.ts +4 -0
- package/dist/components/portal.js +26 -0
- package/dist/components/types.d.ts +7 -0
- package/dist/components/types.js +1 -0
- package/dist/config.d.ts +51 -0
- package/dist/config.js +56 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/module.d.ts +19 -0
- package/dist/processor/blurhash.d.ts +7 -0
- package/dist/processor/blurhash.js +37 -0
- package/dist/processor/color.d.ts +5 -0
- package/dist/processor/color.js +32 -0
- package/dist/processor/config.d.ts +12 -0
- package/dist/processor/config.js +9 -0
- package/dist/processor/exif/converters.d.ts +7 -0
- package/dist/processor/exif/converters.js +38 -0
- package/dist/processor/exif/defaults.d.ts +17 -0
- package/dist/processor/exif/defaults.js +17 -0
- package/dist/processor/exif/exif.d.ts +34 -0
- package/dist/processor/exif/exif.js +43 -0
- package/dist/processor/exif/index.d.ts +1 -0
- package/dist/processor/exif/index.js +1 -0
- package/dist/processor/exif/types.d.ts +4 -0
- package/dist/processor/exif/types.js +1 -0
- package/dist/processor/file.d.ts +3 -0
- package/dist/processor/file.js +28 -0
- package/dist/processor/index.d.ts +27 -0
- package/dist/processor/index.js +70 -0
- package/dist/processor/test-data/canon-m6-22mm.jpg +0 -0
- package/dist/processor/test-data/iphone-15pro.jpg +0 -0
- package/dist/processor/test-data/nikon-z6iii-40mm.jpg +0 -0
- package/dist/processor/test-data/ricoh-gr-iiix.jpg +0 -0
- package/dist/processor/variants.d.ts +13 -0
- package/dist/processor/variants.js +83 -0
- package/dist/remark.d.ts +5 -0
- package/dist/remark.js +268 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.js +1 -0
- package/dist/stores/registry.svelte.d.ts +22 -0
- package/dist/stores/registry.svelte.js +100 -0
- package/dist/test-setup.d.ts +9 -0
- package/dist/test-setup.js +25 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +158 -0
- package/package.json +143 -5
package/dist/vite.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { SpanStatusCode, context, trace } from '@opentelemetry/api';
|
|
2
|
+
import { dataToEsm } from '@rollup/pluginutils';
|
|
3
|
+
import mime from 'mime';
|
|
4
|
+
import { createReadStream } from 'node:fs';
|
|
5
|
+
import { cp, readFile, stat } from 'node:fs/promises';
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { load } from './config.js';
|
|
8
|
+
import processor, {} from './processor/index.js';
|
|
9
|
+
const tracer = trace.getTracer('zone5-vite');
|
|
10
|
+
// Store active spans for module resolution chains
|
|
11
|
+
const moduleSpans = new Map();
|
|
12
|
+
const createBasePath = (namespace, base) => (base?.replace(/\/$/, '') || '') + `/${namespace}/`;
|
|
13
|
+
const parseURL = (rawURL) => {
|
|
14
|
+
return new URL(rawURL.replace(/#/g, '%23'), 'file://');
|
|
15
|
+
};
|
|
16
|
+
const serve = (basePath, cacheDir) => async (req, res, next) => {
|
|
17
|
+
if (req.url?.startsWith(basePath)) {
|
|
18
|
+
const [, id] = req.url.split(basePath);
|
|
19
|
+
try {
|
|
20
|
+
const path = decodeURIComponent(id);
|
|
21
|
+
const src = join(cacheDir, path);
|
|
22
|
+
try {
|
|
23
|
+
const image = createReadStream(src);
|
|
24
|
+
const stats = await stat(src);
|
|
25
|
+
res.setHeader('Content-Type', mime.getType(src) ?? 'binary/octet');
|
|
26
|
+
res.setHeader('Content-Length', stats.size);
|
|
27
|
+
res.setHeader('Cache-Control', 'max-age=360000');
|
|
28
|
+
return image.pipe(res);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error(`can not find zone5 data for ${id}`);
|
|
32
|
+
console.error(error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
res.statusCode = 404;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
next();
|
|
40
|
+
};
|
|
41
|
+
export function zone5(cwd) {
|
|
42
|
+
let viteConfig;
|
|
43
|
+
let basePath;
|
|
44
|
+
let zone5Config;
|
|
45
|
+
return {
|
|
46
|
+
name: 'zone5',
|
|
47
|
+
enforce: 'pre',
|
|
48
|
+
async configResolved(cfg) {
|
|
49
|
+
viteConfig = cfg;
|
|
50
|
+
zone5Config = await load(cwd);
|
|
51
|
+
basePath = createBasePath(zone5Config.base.namespace, viteConfig.base);
|
|
52
|
+
},
|
|
53
|
+
async resolveId(id, importer) {
|
|
54
|
+
const srcURL = parseURL(id);
|
|
55
|
+
if (srcURL.searchParams.get('z5') !== null) {
|
|
56
|
+
if (importer && !id.startsWith('/')) {
|
|
57
|
+
id = join(dirname(importer), id);
|
|
58
|
+
}
|
|
59
|
+
return `\0${id}`;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
async load(id, options) {
|
|
63
|
+
const srcURL = parseURL(id);
|
|
64
|
+
if (srcURL.pathname.endsWith('.jpg') && srcURL.searchParams.get('z5') !== null) {
|
|
65
|
+
// Find parent span context from the importer
|
|
66
|
+
const importer = options?.ssr ? undefined : id;
|
|
67
|
+
let parentContext;
|
|
68
|
+
// Try to find parent span from any matching importer
|
|
69
|
+
for (const [importerPath, spanData] of moduleSpans.entries()) {
|
|
70
|
+
if (importer?.startsWith(importerPath) || id.includes(importerPath)) {
|
|
71
|
+
parentContext = spanData.context;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Execute span creation within parent context if available
|
|
76
|
+
const executeInContext = async () => {
|
|
77
|
+
return tracer.startActiveSpan('zone5.load', async (span) => {
|
|
78
|
+
try {
|
|
79
|
+
span.setAttributes({
|
|
80
|
+
'zone5.id': id,
|
|
81
|
+
'zone5.pathname': srcURL.pathname,
|
|
82
|
+
});
|
|
83
|
+
const featureFile = await processor({
|
|
84
|
+
...zone5Config,
|
|
85
|
+
sourceFile: srcURL.pathname,
|
|
86
|
+
});
|
|
87
|
+
const item = JSON.parse(await readFile(featureFile, { encoding: 'utf-8' }));
|
|
88
|
+
item.assets.forEach((asset) => {
|
|
89
|
+
asset.href = join(basePath, asset.href);
|
|
90
|
+
});
|
|
91
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
92
|
+
return dataToEsm(item, {
|
|
93
|
+
namedExports: true,
|
|
94
|
+
compact: viteConfig.build.minify !== false,
|
|
95
|
+
preferConst: true,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
span.setStatus({
|
|
100
|
+
code: SpanStatusCode.ERROR,
|
|
101
|
+
message: error instanceof Error ? error.message : String(error),
|
|
102
|
+
});
|
|
103
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
104
|
+
console.error(`can not find zone5 data for ${id}`);
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
span.end();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
return parentContext ? context.with(parentContext, executeInContext) : executeInContext();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
configureServer(server) {
|
|
116
|
+
server.middlewares.use(serve(basePath, zone5Config.base.cache));
|
|
117
|
+
},
|
|
118
|
+
configurePreviewServer(server) {
|
|
119
|
+
server.middlewares.use(serve(basePath, zone5Config.base.cache));
|
|
120
|
+
},
|
|
121
|
+
buildEnd() {
|
|
122
|
+
// Close all open parent spans and clean up
|
|
123
|
+
for (const [, spanData] of moduleSpans.entries()) {
|
|
124
|
+
spanData.span.end();
|
|
125
|
+
}
|
|
126
|
+
moduleSpans.clear();
|
|
127
|
+
},
|
|
128
|
+
async writeBundle() {
|
|
129
|
+
if (viteConfig.command === 'build') {
|
|
130
|
+
return tracer.startActiveSpan('zone5.writeBundle', async (span) => {
|
|
131
|
+
try {
|
|
132
|
+
const outDir = viteConfig.build.outDir;
|
|
133
|
+
const targetDir = join(outDir, zone5Config.base.namespace);
|
|
134
|
+
span.setAttributes({
|
|
135
|
+
'zone5.outDir': outDir,
|
|
136
|
+
'zone5.targetDir': targetDir,
|
|
137
|
+
'zone5.namespace': zone5Config.base.namespace,
|
|
138
|
+
});
|
|
139
|
+
await cp(zone5Config.base.cache, targetDir, { recursive: true });
|
|
140
|
+
console.log(`Copied Zone5 cache to ${targetDir}`);
|
|
141
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
span.setStatus({
|
|
145
|
+
code: SpanStatusCode.ERROR,
|
|
146
|
+
message: error instanceof Error ? error.message : String(error),
|
|
147
|
+
});
|
|
148
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
span.end();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,148 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zone5",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"url": "https://github.com/cwygoda/zone5"
|
|
6
|
+
},
|
|
4
7
|
"license": "MIT",
|
|
5
8
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
9
|
+
"bin": {
|
|
10
|
+
"zone5": "./dist/cli/index.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build:cli": "vite build --config vite.cli.config.ts",
|
|
14
|
+
"build:watch": "vite build --watch",
|
|
15
|
+
"build": "svelte-kit sync && svelte-package && pnpm build:cli && publint",
|
|
16
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
17
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
18
|
+
"dev": "vite dev",
|
|
19
|
+
"format": "prettier --write .",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"test:all": "export CI=1; pnpm test && pnpm test:ui && pnpm test:cli && pnpm test:e2e",
|
|
22
|
+
"test:cli": "vitest src/cli",
|
|
23
|
+
"test:e2e": "playwright test",
|
|
24
|
+
"test:ui": "echo 'No UI integration tests yet' && exit 0",
|
|
25
|
+
"test": "vitest --exclude '**/cli/**'",
|
|
26
|
+
"dagger:test": "dagger -m ./dagger call test --source=.",
|
|
27
|
+
"dagger:test:cli": "dagger -m ./dagger call test-cli --source=.",
|
|
28
|
+
"dagger:test:e2e": "dagger -m ./dagger call test-e2e --source=.",
|
|
29
|
+
"dagger:test:all": "dagger -m ./dagger call test-all --source=.",
|
|
30
|
+
"dagger:check": "dagger -m ./dagger call check --source=.",
|
|
31
|
+
"dagger:lint": "dagger -m ./dagger call lint --source=.",
|
|
32
|
+
"dagger:ci": "dagger -m ./dagger call ci --source=.",
|
|
33
|
+
"prepare": "husky"
|
|
34
|
+
},
|
|
35
|
+
"lint-staged": {
|
|
36
|
+
"*.{js,ts,svelte}": [
|
|
37
|
+
"eslint --fix",
|
|
38
|
+
"prettier --write"
|
|
39
|
+
],
|
|
40
|
+
"*.{json,md}": [
|
|
41
|
+
"prettier --write"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"svelte": "./dist/index.js",
|
|
48
|
+
"default": "./dist/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./components": {
|
|
51
|
+
"types": "./dist/components/index.d.ts",
|
|
52
|
+
"svelte": "./dist/components/index.js",
|
|
53
|
+
"default": "./dist/components/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./components/atoms": {
|
|
56
|
+
"types": "./dist/components/atoms/index.d.ts",
|
|
57
|
+
"svelte": "./dist/components/atoms/index.js",
|
|
58
|
+
"default": "./dist/components/atoms/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./vite": {
|
|
61
|
+
"types": "./dist/vite.d.ts",
|
|
62
|
+
"default": "./dist/vite.js"
|
|
63
|
+
},
|
|
64
|
+
"./remark": {
|
|
65
|
+
"types": "./dist/remark.d.ts",
|
|
66
|
+
"default": "./dist/remark.js"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"dist",
|
|
71
|
+
"!dist/**/*.test.*",
|
|
72
|
+
"!dist/**/*.spec.*"
|
|
73
|
+
],
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"@lucide/svelte": "^0.553.0",
|
|
76
|
+
"@sveltejs/kit": "^2.0.0",
|
|
77
|
+
"svelte": "^5.0.0",
|
|
78
|
+
"tailwindcss": "^4.0.0",
|
|
79
|
+
"vite": "^7.0.0"
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@commitlint/cli": "^20.1.0",
|
|
83
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
84
|
+
"@dagger.io/dagger": "^0.19.6",
|
|
85
|
+
"@lucide/svelte": "0.553.0",
|
|
86
|
+
"@playwright/test": "^1.56.1",
|
|
87
|
+
"@sveltejs/kit": "^2.48.4",
|
|
88
|
+
"@sveltejs/package": "^2.3.7",
|
|
89
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
90
|
+
"@testing-library/svelte": "^5.2.8",
|
|
91
|
+
"@types/connect": "^3.4.38",
|
|
92
|
+
"@types/fs-extra": "^11.0.4",
|
|
93
|
+
"@types/jsdom": "^27.0.0",
|
|
94
|
+
"@types/mdast": "^4.0.4",
|
|
95
|
+
"@types/node": "^24.10.0",
|
|
96
|
+
"@types/prompts": "^2.4.9",
|
|
97
|
+
"husky": "^9.1.7",
|
|
98
|
+
"jsdom": "^27.1.0",
|
|
99
|
+
"mdsvex": "^0.12.6",
|
|
100
|
+
"publint": "^0.3.15",
|
|
101
|
+
"semantic-release": "^25.0.2",
|
|
102
|
+
"svast": "^0.2.1",
|
|
103
|
+
"svelte": "^5.43.5",
|
|
104
|
+
"svelte-check": "^4.3.3",
|
|
105
|
+
"tailwindcss": "^4.1.17",
|
|
106
|
+
"typescript": "^5.9.3",
|
|
107
|
+
"vite": "^7.2.2",
|
|
108
|
+
"vitest": "^4.0.8"
|
|
109
|
+
},
|
|
110
|
+
"dependencies": {
|
|
111
|
+
"@eslint/js": "^9.39.1",
|
|
112
|
+
"@opentelemetry/api": "^1.9.0",
|
|
113
|
+
"@rollup/pluginutils": "^5.3.0",
|
|
114
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
115
|
+
"@semantic-release/git": "^10.0.1",
|
|
116
|
+
"@tailwindcss/vite": "^4.1.17",
|
|
117
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.0",
|
|
118
|
+
"blurhash": "^2.0.5",
|
|
119
|
+
"commander": "^13.1.0",
|
|
120
|
+
"dayjs": "^1.11.19",
|
|
121
|
+
"eslint": "^9.39.1",
|
|
122
|
+
"eslint-config-prettier": "^10.1.8",
|
|
123
|
+
"eslint-plugin-svelte": "^3.13.0",
|
|
124
|
+
"exifr": "^7.1.3",
|
|
125
|
+
"fast-average-color-node": "^3.1.0",
|
|
126
|
+
"fs-extra": "^11.2.0",
|
|
127
|
+
"globals": "^16.5.0",
|
|
128
|
+
"mime": "^4.1.0",
|
|
129
|
+
"ora": "^9.0.0",
|
|
130
|
+
"picocolors": "^1.1.1",
|
|
131
|
+
"prettier": "^3.6.2",
|
|
132
|
+
"prettier-plugin-svelte": "^3.4.0",
|
|
133
|
+
"prompts": "^2.4.2",
|
|
134
|
+
"remark": "^15.0.1",
|
|
135
|
+
"sharp": "^0.34.5",
|
|
136
|
+
"smol-toml": "^1.4.2",
|
|
137
|
+
"svast-stringify": "^0.1.1",
|
|
138
|
+
"sveltekit-search-params": "^3.0.0",
|
|
139
|
+
"typescript-eslint": "^8.47.0",
|
|
140
|
+
"unified": "^11.0.5",
|
|
141
|
+
"unist-util-visit": "^5.0.0",
|
|
142
|
+
"vfile": "^6.0.3",
|
|
143
|
+
"zod": "^4.1.12",
|
|
144
|
+
"zod-config": "^1.4.0"
|
|
145
|
+
},
|
|
146
|
+
"svelte": "./dist/index.js",
|
|
147
|
+
"types": "./dist/index.d.ts"
|
|
10
148
|
}
|