chartout 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.
@@ -0,0 +1,3 @@
1
+ export { createChartoutModel } from '../model';
2
+ export type { ChartoutModel, ChartoutState } from '../model';
3
+ export type { CartItem, ActiveItem, ActiveTexture, StoreView, ShippingLocation } from './widget';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Public state types for the chartout widget.
3
+ *
4
+ * These are the types you work with when calling model.set() / model.get().
5
+ * They intentionally omit internal positioning fields (user_position,
6
+ * print_size, etc.) that the widget manages itself after you supply the bytes.
7
+ */
8
+ /** A single print placement — PNG bytes for one area of the product. */
9
+ export interface Placement {
10
+ id: string;
11
+ content: Uint8Array | string;
12
+ }
13
+ /** A cart line item — one product variant with its print content. */
14
+ export interface CartItem {
15
+ id: string;
16
+ name: string;
17
+ quantity: number;
18
+ placements: Placement[];
19
+ price?: number;
20
+ variant_id?: number;
21
+ product_id?: number;
22
+ }
23
+ /** The item currently shown in the 3D viewer. */
24
+ export interface ActiveItem {
25
+ id: string;
26
+ name: string;
27
+ placements: Placement[];
28
+ }
29
+ /** The rendered composite texture written back by the widget. */
30
+ export interface ActiveTexture {
31
+ texture: Uint8Array;
32
+ }
33
+ /** Which view the store UI shows. */
34
+ export type StoreView = 'cart' | 'checkout';
35
+ /** Shipping location used to pre-fill the checkout country/state selector. */
36
+ export interface ShippingLocation {
37
+ country: string;
38
+ state: string;
39
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "chartout",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./bundle/lib.js",
8
+ "types": "./bundle/types/index.d.ts"
9
+ },
10
+ "./render": {
11
+ "import": "./bundle/render.js"
12
+ }
13
+ },
14
+ "types": "./bundle/types/index.d.ts",
15
+ "files": ["bundle/Widget.js", "bundle/lib.js", "bundle/render.js", "bundle/types", "bundle/components"],
16
+ "scripts": {
17
+ "build": "npm run buildwidget && npm run buildlib && npm run buildrender && npm run buildtypes",
18
+ "buildtypes": "tsc -p tsconfig.types.json",
19
+ "devwidget": "cross-env NODE_ENV=development ./node_modules/.bin/esbuild ./src/Widget.tsx --format=esm --outdir=./bundle --bundle --define:process.env.NODE_ENV='\"development\"' --watch",
20
+ "devlib": "cross-env NODE_ENV=development ./node_modules/.bin/esbuild ./src/lib.ts --format=esm --outdir=./bundle --bundle --external:react --external:react-dom --define:process.env.NODE_ENV='\"development\"' --watch",
21
+ "devrender": "cross-env NODE_ENV=development ./node_modules/.bin/esbuild ./src/widgetRender.tsx --format=esm --outfile=./bundle/render.js --bundle --external:react --external:react-dom --external:@anywidget/react --external:react-reconciler --define:process.env.NODE_ENV='\"development\"' --watch",
22
+ "buildwidget": "cross-env NODE_ENV=production ./node_modules/.bin/esbuild ./src/Widget.tsx --format=esm --outdir=./bundle --bundle --define:process.env.NODE_ENV='\"production\"'",
23
+ "buildlib": "cross-env NODE_ENV=production ./node_modules/.bin/esbuild ./src/lib.ts --format=esm --outdir=./bundle --bundle --external:react --external:react-dom --define:process.env.NODE_ENV='\"production\"'",
24
+ "buildrender": "cross-env NODE_ENV=production ./node_modules/.bin/esbuild ./src/widgetRender.tsx --format=esm --outfile=./bundle/render.js --bundle --external:react --external:react-dom --external:@anywidget/react --external:react-reconciler --define:process.env.NODE_ENV='\"production\"'",
25
+ "serve": "npx serve ./bundle",
26
+ "dev": "concurrently \"npm run devwidget\" \"npm run devrender\" \"npm run serve\""
27
+ },
28
+ "dependencies": {
29
+ "@anywidget/react": "^0.2.0",
30
+ "@react-three/drei": "^9.115.0",
31
+ "@react-three/fiber": "^8.17.10",
32
+ "react": "^18.2.0",
33
+ "react-dom": "^18.2.0",
34
+ "react-icons": "^5.5.0",
35
+ "skia-canvas": "^2.0.1",
36
+ "three": "^0.168.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.10.2",
40
+ "@types/react": "^18.0.37",
41
+ "@types/react-dom": "^18.0.11",
42
+ "@types/three": "^0.168.0",
43
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
44
+ "@typescript-eslint/parser": "^5.59.0",
45
+ "@vitejs/plugin-react": "^4.0.0",
46
+ "autoprefixer": "^10.4.21",
47
+ "concurrently": "^8.2.2",
48
+ "cross-env": "^7.0.3",
49
+ "esbuild": "0.18.10",
50
+ "eslint": "^8.38.0",
51
+ "eslint-plugin-react-hooks": "^4.6.0",
52
+ "eslint-plugin-react-refresh": "^0.3.4",
53
+ "postcss": "^8.5.3",
54
+ "tailwindcss": "^4.1.7",
55
+ "typescript": "^6.0.3"
56
+ }
57
+ }