@tailorkit/app 0.1.0-beta.8 → 1.0.0-beta.44
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.md +74 -0
- package/README.md +123 -0
- package/dist/chunk-7ZQPXG7O.js +34 -0
- package/dist/chunk-MYK3WL3S.js +428 -0
- package/dist/chunk-QDZXHVTU.js +277 -0
- package/dist/chunk-YFKW5FBP.js +623 -0
- package/dist/client/connection.d.ts +31 -0
- package/dist/client/query-store.d.ts +23 -0
- package/dist/client/reference.d.ts +20 -0
- package/dist/client/session.d.ts +20 -0
- package/dist/client/tools.d.ts +16 -0
- package/dist/client-connection.js +16 -0
- package/dist/client.d.ts +11 -0
- package/dist/client.js +40 -0
- package/dist/database/definition.d.ts +8 -0
- package/dist/database/schema.d.ts +78 -0
- package/dist/database/types.d.ts +8 -0
- package/dist/errors.d.ts +6 -0
- package/dist/index.d.ts +2 -71
- package/dist/index.js +91 -75
- package/dist/preact.d.ts +52 -0
- package/dist/protocol.d.ts +74 -0
- package/dist/protocol.js +39 -0
- package/dist/routing.d.ts +35 -0
- package/dist/server/builder.d.ts +46 -0
- package/dist/server/bundle.d.ts +12 -0
- package/dist/server/functions.d.ts +113 -0
- package/dist/server/instances.d.ts +17 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +60 -0
- package/dist/validation.d.ts +5 -0
- package/dist/views.d.ts +126 -0
- package/package.json +59 -22
- package/LICENSE +0 -674
- package/dist/builder/index.d.ts +0 -10
- package/dist/builder/upload-manifest.d.ts +0 -13
- package/dist/builder.js +0 -224
- package/dist/chunk-EKCUETAV.js +0 -26
- package/dist/chunk-ZFYKVXDO.js +0 -27
- package/dist/config/config.d.ts +0 -20
- package/dist/config/index.d.ts +0 -1
- package/dist/config/loader.d.ts +0 -7
- package/dist/config-loader.js +0 -7
- package/dist/config.js +0 -8
- package/dist/preact-version.d.ts +0 -7
package/dist/builder/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { createTailorKitUploadManifest, tailorkitUploadManifestSchema, type TailorKitUploadManifest, } from "./upload-manifest";
|
|
2
|
-
export interface BuildAppOptions {
|
|
3
|
-
configPath?: string;
|
|
4
|
-
cwd?: string;
|
|
5
|
-
entry?: string;
|
|
6
|
-
mode?: string;
|
|
7
|
-
outDir?: string;
|
|
8
|
-
watch?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const buildApp: (options?: BuildAppOptions) => Promise<unknown>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const tailorkitUploadManifestSchema: z.ZodObject<{
|
|
3
|
-
assets: z.ZodObject<{
|
|
4
|
-
client: z.ZodLiteral<"client.js">;
|
|
5
|
-
logos: z.ZodOptional<z.ZodObject<{
|
|
6
|
-
dark: z.ZodOptional<z.ZodString>;
|
|
7
|
-
light: z.ZodOptional<z.ZodString>;
|
|
8
|
-
}, z.core.$strip>>;
|
|
9
|
-
}, z.core.$strip>;
|
|
10
|
-
version: z.ZodLiteral<1>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
export type TailorKitUploadManifest = z.output<typeof tailorkitUploadManifestSchema>;
|
|
13
|
-
export declare const createTailorKitUploadManifest: (logos?: TailorKitUploadManifest["assets"]["logos"]) => TailorKitUploadManifest;
|
package/dist/builder.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadTailorKitConfig
|
|
3
|
-
} from "./chunk-EKCUETAV.js";
|
|
4
|
-
import "./chunk-ZFYKVXDO.js";
|
|
5
|
-
|
|
6
|
-
// src/builder/index.ts
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { createRequire } from "module";
|
|
9
|
-
import { readFile, writeFile } from "fs/promises";
|
|
10
|
-
|
|
11
|
-
// ../asset-delivery/dist/logo-validation.mjs
|
|
12
|
-
var maxLogoBytes = 262144;
|
|
13
|
-
var maxLogoDimension = 2048;
|
|
14
|
-
var readPngDimensions = (content) => {
|
|
15
|
-
if (content.length < 33 || ![
|
|
16
|
-
137,
|
|
17
|
-
80,
|
|
18
|
-
78,
|
|
19
|
-
71,
|
|
20
|
-
13,
|
|
21
|
-
10,
|
|
22
|
-
26,
|
|
23
|
-
10
|
|
24
|
-
].every((byte, index) => content[index] === byte)) throw new Error("Logo content is not a valid PNG file.");
|
|
25
|
-
const view = new DataView(content.buffer, content.byteOffset, content.byteLength);
|
|
26
|
-
const isIhdr = content[12] === 73 && content[13] === 72 && content[14] === 68 && content[15] === 82;
|
|
27
|
-
if (view.getUint32(8) !== 13 || !isIhdr) throw new Error("Logo content is not a valid PNG file.");
|
|
28
|
-
return {
|
|
29
|
-
width: view.getUint32(16),
|
|
30
|
-
height: view.getUint32(20)
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
var readWebpDimensions = (content) => {
|
|
34
|
-
const text = (start, end) => new TextDecoder().decode(content.subarray(start, end));
|
|
35
|
-
if (content.length < 30 || text(0, 4) !== "RIFF" || text(8, 12) !== "WEBP") throw new Error("Logo content is not a valid WebP file.");
|
|
36
|
-
const view = new DataView(content.buffer, content.byteOffset, content.byteLength);
|
|
37
|
-
const chunk = text(12, 16);
|
|
38
|
-
if (chunk === "VP8X") return {
|
|
39
|
-
width: 1 + view.getUint16(24, true) + (content[26] ?? 0) * 65536,
|
|
40
|
-
height: 1 + view.getUint16(27, true) + (content[29] ?? 0) * 65536
|
|
41
|
-
};
|
|
42
|
-
if (chunk === "VP8L" && content[20] === 47) {
|
|
43
|
-
const bits = view.getUint32(21, true);
|
|
44
|
-
return {
|
|
45
|
-
width: bits % 16384 + 1,
|
|
46
|
-
height: Math.floor(bits / 16384) % 16384 + 1
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (chunk === "VP8 " && content[23] === 157 && content[24] === 1 && content[25] === 42) return {
|
|
50
|
-
width: view.getUint16(26, true) % 16384,
|
|
51
|
-
height: view.getUint16(28, true) % 16384
|
|
52
|
-
};
|
|
53
|
-
throw new Error("Logo content is not a supported WebP file.");
|
|
54
|
-
};
|
|
55
|
-
var validateSvg = (content) => {
|
|
56
|
-
const svg = new TextDecoder("utf-8", {
|
|
57
|
-
fatal: true,
|
|
58
|
-
ignoreBOM: false
|
|
59
|
-
}).decode(content);
|
|
60
|
-
if (!/<svg(?:\s|>)/iu.test(svg)) throw new Error("Logo content is not a valid SVG file.");
|
|
61
|
-
if (/<(?:script|foreignObject|iframe|object|embed)(?:\s|>)/iu.test(svg) || /\son[a-z]+\s*=/iu.test(svg) || /(?:href|src)\s*=\s*["'](?!#)/iu.test(svg) || /(?:@import|url\(\s*(?!["']?#))/iu.test(svg) || /<!DOCTYPE|<!ENTITY|<\?xml-stylesheet/iu.test(svg)) throw new Error("SVG logos cannot contain scripts or external resources.");
|
|
62
|
-
};
|
|
63
|
-
function validateLogoAsset(content, contentType) {
|
|
64
|
-
if (content.byteLength < 1 || content.byteLength > 262144) throw new Error(`Logo must be between 1 and ${maxLogoBytes} bytes.`);
|
|
65
|
-
if (contentType === "image/svg+xml") {
|
|
66
|
-
validateSvg(content);
|
|
67
|
-
return {};
|
|
68
|
-
}
|
|
69
|
-
const dimensions = contentType === "image/png" ? readPngDimensions(content) : readWebpDimensions(content);
|
|
70
|
-
if (dimensions.width < 1 || dimensions.height < 1 || dimensions.width > 2048 || dimensions.height > 2048) throw new Error(`Raster logos cannot exceed ${maxLogoDimension} by ${maxLogoDimension} pixels.`);
|
|
71
|
-
return dimensions;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/builder/index.ts
|
|
75
|
-
import { build as viteBuild } from "vite";
|
|
76
|
-
|
|
77
|
-
// src/preact-version.ts
|
|
78
|
-
var MINIMUM_PREACT_MAJOR_VERSION = 10;
|
|
79
|
-
var parsePreactVersion = (version) => {
|
|
80
|
-
const match = /^(\d+)\./u.exec(version);
|
|
81
|
-
if (!match?.[1]) {
|
|
82
|
-
throw new Error(`Unable to parse Preact version "${version}".`);
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
major: Number.parseInt(match[1], 10),
|
|
86
|
-
version
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
var assertSupportedPreactVersion = (version) => {
|
|
90
|
-
const check = parsePreactVersion(version);
|
|
91
|
-
if (check.major < MINIMUM_PREACT_MAJOR_VERSION) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`TailorKit requires Preact ${MINIMUM_PREACT_MAJOR_VERSION}.0.0 or newer, but found ${version}.`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
return check;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// src/builder/upload-manifest.ts
|
|
100
|
-
import { z } from "zod";
|
|
101
|
-
var tailorkitUploadManifestSchema = z.object({
|
|
102
|
-
assets: z.object({
|
|
103
|
-
client: z.literal("client.js"),
|
|
104
|
-
logos: z.object({
|
|
105
|
-
dark: z.string().regex(/^logo-dark\.(?:png|svg|webp)$/u).optional(),
|
|
106
|
-
light: z.string().regex(/^logo-light\.(?:png|svg|webp)$/u).optional()
|
|
107
|
-
}).optional()
|
|
108
|
-
}),
|
|
109
|
-
version: z.literal(1)
|
|
110
|
-
});
|
|
111
|
-
var createTailorKitUploadManifest = (logos) => tailorkitUploadManifestSchema.parse({
|
|
112
|
-
assets: {
|
|
113
|
-
client: "client.js",
|
|
114
|
-
...logos && Object.keys(logos).length > 0 ? { logos } : {}
|
|
115
|
-
},
|
|
116
|
-
version: 1
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// src/builder/index.ts
|
|
120
|
-
var preactPackageJson = "preact/package.json";
|
|
121
|
-
var preactPackageJsonModuleId = "\0tailorkit-preact-package-json";
|
|
122
|
-
var buildApp = async (options = {}) => {
|
|
123
|
-
const loaded = await loadTailorKitConfig(options.configPath, options.cwd);
|
|
124
|
-
const entry = options.entry ?? loaded.config.client?.entry ?? "./src/client.ts";
|
|
125
|
-
const outDir = options.outDir ?? loaded.config.build?.outDir ?? ".tailorkit";
|
|
126
|
-
const preactVersion = getInstalledPreactVersion(loaded.root);
|
|
127
|
-
assertSupportedPreactVersion(preactVersion);
|
|
128
|
-
const resolvedOutDir = path.resolve(loaded.root, outDir);
|
|
129
|
-
const result = await viteBuild({
|
|
130
|
-
build: {
|
|
131
|
-
emptyOutDir: true,
|
|
132
|
-
lib: {
|
|
133
|
-
entry: path.resolve(loaded.root, entry),
|
|
134
|
-
fileName: "client",
|
|
135
|
-
formats: ["es"]
|
|
136
|
-
},
|
|
137
|
-
outDir: resolvedOutDir,
|
|
138
|
-
watch: options.watch ? {} : null,
|
|
139
|
-
minify: "oxc",
|
|
140
|
-
rollupOptions: {
|
|
141
|
-
output: {
|
|
142
|
-
comments: {
|
|
143
|
-
annotation: false,
|
|
144
|
-
jsdoc: false,
|
|
145
|
-
legal: false
|
|
146
|
-
},
|
|
147
|
-
minify: true,
|
|
148
|
-
minifyInternalExports: true
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
configFile: false,
|
|
153
|
-
mode: options.mode,
|
|
154
|
-
plugins: [
|
|
155
|
-
{
|
|
156
|
-
name: "tailorkit-preact-package-json",
|
|
157
|
-
enforce: "pre",
|
|
158
|
-
resolveId(id) {
|
|
159
|
-
if (id === preactPackageJson) {
|
|
160
|
-
return preactPackageJsonModuleId;
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
},
|
|
164
|
-
load(id) {
|
|
165
|
-
if (id === preactPackageJsonModuleId) {
|
|
166
|
-
const version = JSON.stringify(preactVersion);
|
|
167
|
-
return `export const version = ${version}; export default { version: ${version} };`;
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
],
|
|
173
|
-
root: loaded.root
|
|
174
|
-
});
|
|
175
|
-
const logoManifest = {};
|
|
176
|
-
for (const variant of ["light", "dark"]) {
|
|
177
|
-
const configuredPath = loaded.config.logos?.[variant];
|
|
178
|
-
if (!configuredPath) {
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
const extension = path.extname(configuredPath).toLowerCase().slice(1);
|
|
182
|
-
const contentType = {
|
|
183
|
-
png: "image/png",
|
|
184
|
-
svg: "image/svg+xml",
|
|
185
|
-
webp: "image/webp"
|
|
186
|
-
}[extension];
|
|
187
|
-
if (!contentType) {
|
|
188
|
-
throw new Error(`The ${variant} logo must be an SVG, PNG, or WebP file.`);
|
|
189
|
-
}
|
|
190
|
-
const content = await readFile(path.resolve(loaded.root, configuredPath));
|
|
191
|
-
validateLogoAsset(content, contentType);
|
|
192
|
-
const filename = `logo-${variant}.${extension}`;
|
|
193
|
-
await writeFile(path.join(resolvedOutDir, filename), content);
|
|
194
|
-
logoManifest[variant] = filename;
|
|
195
|
-
}
|
|
196
|
-
await writeFile(
|
|
197
|
-
path.join(resolvedOutDir, "tailorkit-upload.json"),
|
|
198
|
-
`${JSON.stringify(createTailorKitUploadManifest(logoManifest), null, 2)}
|
|
199
|
-
`,
|
|
200
|
-
"utf-8"
|
|
201
|
-
);
|
|
202
|
-
return result;
|
|
203
|
-
};
|
|
204
|
-
function getInstalledPreactVersion(root) {
|
|
205
|
-
const require2 = createRequire(path.join(root, "package.json"));
|
|
206
|
-
try {
|
|
207
|
-
const packageJsonPath = require2.resolve("preact/package.json");
|
|
208
|
-
const packageJson = require2(packageJsonPath);
|
|
209
|
-
if (typeof packageJson.version === "string") {
|
|
210
|
-
return packageJson.version;
|
|
211
|
-
}
|
|
212
|
-
} catch (error) {
|
|
213
|
-
throw new Error(
|
|
214
|
-
`TailorKit requires Preact to build an app. Install preact@^10 and try again.`,
|
|
215
|
-
{ cause: error }
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
throw new Error("Unable to read the installed Preact version.");
|
|
219
|
-
}
|
|
220
|
-
export {
|
|
221
|
-
buildApp,
|
|
222
|
-
createTailorKitUploadManifest,
|
|
223
|
-
tailorkitUploadManifestSchema
|
|
224
|
-
};
|
package/dist/chunk-EKCUETAV.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
tailorkitConfigSchema
|
|
3
|
-
} from "./chunk-ZFYKVXDO.js";
|
|
4
|
-
|
|
5
|
-
// src/config/loader.ts
|
|
6
|
-
import { cosmiconfig } from "cosmiconfig";
|
|
7
|
-
import path from "path";
|
|
8
|
-
var explorer = cosmiconfig("tailorkit", {
|
|
9
|
-
searchPlaces: ["tailorkit.config.ts", "tailorkit.config.mjs", "tailorkit.config.js"]
|
|
10
|
-
});
|
|
11
|
-
var loadTailorKitConfig = async (configPath, cwd = process.cwd()) => {
|
|
12
|
-
const searchFrom = path.resolve(cwd);
|
|
13
|
-
const result = configPath === void 0 ? await explorer.search(searchFrom) : await explorer.load(path.resolve(searchFrom, configPath));
|
|
14
|
-
if (result === null) {
|
|
15
|
-
throw new Error(`Could not find tailorkit config from ${searchFrom}.`);
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
config: tailorkitConfigSchema.parse(result.config),
|
|
19
|
-
filepath: result.filepath,
|
|
20
|
-
root: path.dirname(result.filepath)
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
loadTailorKitConfig
|
|
26
|
-
};
|
package/dist/chunk-ZFYKVXDO.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// src/config/config.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var clientConfigSchema = z.object({
|
|
4
|
-
entry: z.string().default("./src/client.ts")
|
|
5
|
-
});
|
|
6
|
-
var buildConfigSchema = z.object({
|
|
7
|
-
outDir: z.string().default(".tailorkit")
|
|
8
|
-
});
|
|
9
|
-
var logosConfigSchema = z.object({
|
|
10
|
-
dark: z.string().min(1).optional(),
|
|
11
|
-
light: z.string().min(1).optional()
|
|
12
|
-
});
|
|
13
|
-
var tailorkitConfigSchema = z.object({
|
|
14
|
-
appId: z.string().min(1).optional(),
|
|
15
|
-
build: buildConfigSchema.optional(),
|
|
16
|
-
client: clientConfigSchema.optional(),
|
|
17
|
-
host: z.string().url(),
|
|
18
|
-
logos: logosConfigSchema.optional()
|
|
19
|
-
});
|
|
20
|
-
var defineConfig = (config) => config;
|
|
21
|
-
var defineTailorKitConfig = defineConfig;
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
tailorkitConfigSchema,
|
|
25
|
-
defineConfig,
|
|
26
|
-
defineTailorKitConfig
|
|
27
|
-
};
|
package/dist/config/config.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
declare const tailorkitConfigSchema: z.ZodObject<{
|
|
3
|
-
appId: z.ZodOptional<z.ZodString>;
|
|
4
|
-
build: z.ZodOptional<z.ZodObject<{
|
|
5
|
-
outDir: z.ZodDefault<z.ZodString>;
|
|
6
|
-
}, z.core.$strip>>;
|
|
7
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
8
|
-
entry: z.ZodDefault<z.ZodString>;
|
|
9
|
-
}, z.core.$strip>>;
|
|
10
|
-
host: z.ZodString;
|
|
11
|
-
logos: z.ZodOptional<z.ZodObject<{
|
|
12
|
-
dark: z.ZodOptional<z.ZodString>;
|
|
13
|
-
light: z.ZodOptional<z.ZodString>;
|
|
14
|
-
}, z.core.$strip>>;
|
|
15
|
-
}, z.core.$strip>;
|
|
16
|
-
export type TailorKitConfig = z.input<typeof tailorkitConfigSchema>;
|
|
17
|
-
export type ResolvedTailorKitConfig = z.output<typeof tailorkitConfigSchema>;
|
|
18
|
-
export { tailorkitConfigSchema };
|
|
19
|
-
export declare const defineConfig: (config: TailorKitConfig) => TailorKitConfig;
|
|
20
|
-
export declare const defineTailorKitConfig: typeof defineConfig;
|
package/dist/config/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { defineConfig, defineTailorKitConfig, type TailorKitConfig } from "./config";
|
package/dist/config/loader.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ResolvedTailorKitConfig } from "./config";
|
|
2
|
-
export interface LoadedTailorKitConfig {
|
|
3
|
-
config: ResolvedTailorKitConfig;
|
|
4
|
-
filepath: string;
|
|
5
|
-
root: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const loadTailorKitConfig: (configPath: string | undefined, cwd?: string) => Promise<LoadedTailorKitConfig>;
|
package/dist/config-loader.js
DELETED
package/dist/config.js
DELETED
package/dist/preact-version.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const MINIMUM_PREACT_MAJOR_VERSION = 10;
|
|
2
|
-
export interface PreactVersionCheck {
|
|
3
|
-
major: number;
|
|
4
|
-
version: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const parsePreactVersion: (version: string) => PreactVersionCheck;
|
|
7
|
-
export declare const assertSupportedPreactVersion: (version: string) => PreactVersionCheck;
|