@shopify/klint 0.0.97 → 0.2.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/bin/create-editor +423 -0
- package/bin/create-sandbox +232 -0
- package/bin/klint +146 -0
- package/dist/index.cjs +2369 -317
- package/dist/index.d.cts +847 -66
- package/dist/index.d.ts +847 -66
- package/dist/index.js +2362 -316
- package/package.json +11 -17
- package/dist/elements/index.cjs +0 -946
- package/dist/elements/index.d.cts +0 -658
- package/dist/elements/index.d.ts +0 -658
- package/dist/elements/index.js +0 -913
- package/dist/plugins/index.cjs +0 -1174
- package/dist/plugins/index.d.ts +0 -731
- package/dist/plugins/index.js +0 -1140
package/bin/klint
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
const command = args[0];
|
|
5
|
+
const subArgs = args.slice(1);
|
|
6
|
+
|
|
7
|
+
if (command === "mcp") {
|
|
8
|
+
// Run the MCP server
|
|
9
|
+
import("../../../mcp-server/dist/index.js").catch((err) => {
|
|
10
|
+
console.error("Failed to start MCP server:", err);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
|
13
|
+
} else if (command === "create-editor") {
|
|
14
|
+
// Run the create-editor command
|
|
15
|
+
import("./create-editor").catch((err) => {
|
|
16
|
+
console.error("Failed to run create-editor:", err);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
});
|
|
19
|
+
} else if (command === "add-plugin" || command === "add-plugins") {
|
|
20
|
+
// Add plugin(s)
|
|
21
|
+
const pluginName = subArgs[0];
|
|
22
|
+
const isAll = pluginName === "all" || pluginName === "--all" || subArgs.includes("--all");
|
|
23
|
+
|
|
24
|
+
if (!pluginName && !isAll) {
|
|
25
|
+
console.error("Please specify a plugin name or use --all");
|
|
26
|
+
console.log("Usage: klint add-plugin <plugin-name>");
|
|
27
|
+
console.log(" klint add-plugin --all");
|
|
28
|
+
console.log("\nAvailable plugins:");
|
|
29
|
+
console.log(" font-parser - Parse and render font files");
|
|
30
|
+
console.log(" delaunay - Delaunay triangulation");
|
|
31
|
+
console.log(" catmull - Catmull-Rom spline interpolation");
|
|
32
|
+
console.log(" things - Template plugin for collections");
|
|
33
|
+
console.log(" particle-system - Particle effects system");
|
|
34
|
+
console.log(" --all - Install all plugins");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Simple plugin installer
|
|
39
|
+
const { execSync } = require("child_process");
|
|
40
|
+
const fs = require("fs");
|
|
41
|
+
const path = require("path");
|
|
42
|
+
|
|
43
|
+
// Check if package.json exists
|
|
44
|
+
if (!fs.existsSync("package.json")) {
|
|
45
|
+
console.error("Error: No package.json found in current directory");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Check if @shopify/klint-plugins is already installed
|
|
50
|
+
const pkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
|
|
51
|
+
const hasPlugins =
|
|
52
|
+
(pkg.dependencies && pkg.dependencies["@shopify/klint-plugins"]) ||
|
|
53
|
+
(pkg.devDependencies && pkg.devDependencies["@shopify/klint-plugins"]);
|
|
54
|
+
|
|
55
|
+
if (!hasPlugins) {
|
|
56
|
+
console.log("Installing @shopify/klint-plugins package...");
|
|
57
|
+
execSync("npm install @shopify/klint-plugins", { stdio: "inherit" });
|
|
58
|
+
console.log("✓ @shopify/klint-plugins installed successfully!");
|
|
59
|
+
} else {
|
|
60
|
+
console.log("✓ @shopify/klint-plugins already installed");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Show usage based on what was requested
|
|
64
|
+
if (isAll) {
|
|
65
|
+
console.log("\n✓ All plugins are now available!");
|
|
66
|
+
console.log('\nUsage example:');
|
|
67
|
+
console.log(`
|
|
68
|
+
import { useKlint } from '@shopify/klint';
|
|
69
|
+
import {
|
|
70
|
+
fontParserPlugin,
|
|
71
|
+
delaunayPlugin,
|
|
72
|
+
catmullPlugin,
|
|
73
|
+
thingsPlugin,
|
|
74
|
+
particleSystemPlugin
|
|
75
|
+
} from '@shopify/klint-plugins';
|
|
76
|
+
|
|
77
|
+
const { context, addPlugin } = useKlint();
|
|
78
|
+
|
|
79
|
+
// In your setup function:
|
|
80
|
+
const setup = (ctx) => {
|
|
81
|
+
// Add all plugins at once
|
|
82
|
+
const plugins = addPlugin(
|
|
83
|
+
fontParserPlugin,
|
|
84
|
+
delaunayPlugin,
|
|
85
|
+
catmullPlugin,
|
|
86
|
+
thingsPlugin,
|
|
87
|
+
particleSystemPlugin
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// Or destructure specific ones you need
|
|
91
|
+
const { FontParser, ParticleSystem } = plugins;
|
|
92
|
+
|
|
93
|
+
// Use your plugins
|
|
94
|
+
ParticleSystem.createEmitter({ x: 100, y: 100 });
|
|
95
|
+
};
|
|
96
|
+
`);
|
|
97
|
+
} else {
|
|
98
|
+
// Show specific plugin usage
|
|
99
|
+
const pluginExamples = {
|
|
100
|
+
"font-parser": "FontParser",
|
|
101
|
+
"delaunay": "Delaunay",
|
|
102
|
+
"catmull": "Catmull",
|
|
103
|
+
"things": "Things",
|
|
104
|
+
"particle-system": "ParticleSystem"
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const className = pluginExamples[pluginName] || pluginName;
|
|
108
|
+
const pluginVarName = pluginName.replace(/-/g, "");
|
|
109
|
+
|
|
110
|
+
console.log(`\n✓ Plugin "${pluginName}" is available!`);
|
|
111
|
+
console.log('\nUsage example:');
|
|
112
|
+
console.log(`
|
|
113
|
+
import { useKlint } from '@shopify/klint';
|
|
114
|
+
import { ${pluginVarName}Plugin } from '@shopify/klint-plugins';
|
|
115
|
+
|
|
116
|
+
const { context, addPlugin } = useKlint();
|
|
117
|
+
|
|
118
|
+
// In your setup function:
|
|
119
|
+
const setup = (ctx) => {
|
|
120
|
+
const { ${className} } = addPlugin(${pluginVarName}Plugin);
|
|
121
|
+
|
|
122
|
+
// Use the plugin
|
|
123
|
+
// ${className} is now available with all its methods
|
|
124
|
+
};
|
|
125
|
+
`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
} else if (command === "list-plugins") {
|
|
129
|
+
console.log("\nAvailable Klint Plugins:");
|
|
130
|
+
console.log("------------------------");
|
|
131
|
+
console.log(" font-parser - Parse and render font files");
|
|
132
|
+
console.log(" delaunay - Delaunay triangulation");
|
|
133
|
+
console.log(" catmull - Catmull-Rom spline interpolation");
|
|
134
|
+
console.log(" things - Template plugin for managing collections");
|
|
135
|
+
console.log(" particle-system - Complete particle effects system");
|
|
136
|
+
console.log(" --all - Install all plugins\n");
|
|
137
|
+
} else {
|
|
138
|
+
console.log("Klint CLI");
|
|
139
|
+
console.log("");
|
|
140
|
+
console.log("Commands:");
|
|
141
|
+
console.log(" klint mcp - Start the MCP server for AI assistants");
|
|
142
|
+
console.log(" klint create-editor - Create a new Klint editor project");
|
|
143
|
+
console.log(" klint add-plugin - Add a Klint plugin to your project");
|
|
144
|
+
console.log(" klint list-plugins - List available Klint plugins");
|
|
145
|
+
console.log("");
|
|
146
|
+
}
|