lapikit 0.3.1 → 0.3.3
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/dist/entry-bundler.d.ts +9 -0
- package/dist/entry-bundler.js +64 -0
- package/dist/labs/components/button/button.svelte +24 -0
- package/dist/labs/components/button/button.svelte.d.ts +5 -0
- package/dist/labs/components/index.d.ts +2 -0
- package/dist/labs/components/index.js +3 -0
- package/package.json +10 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { components } from './labs/components/index.js';
|
|
2
|
+
function componentName(shortName) {
|
|
3
|
+
return 'Kit' + shortName.charAt(0).toUpperCase() + shortName.slice(1);
|
|
4
|
+
}
|
|
5
|
+
function lapikitPreprocess() {
|
|
6
|
+
return {
|
|
7
|
+
markup({ content }) {
|
|
8
|
+
const hasComponent = components.some((comp) => content.includes(`<lpk:${comp}`));
|
|
9
|
+
if (!hasComponent)
|
|
10
|
+
return;
|
|
11
|
+
let processedContent = content;
|
|
12
|
+
const importedComponents = new Set();
|
|
13
|
+
let hasChanges = true;
|
|
14
|
+
while (hasChanges) {
|
|
15
|
+
hasChanges = false;
|
|
16
|
+
for (const shortName of components) {
|
|
17
|
+
const componentNameStr = componentName(shortName);
|
|
18
|
+
const regex = new RegExp(`<lpk:${shortName}([\\s\\S]*?)>([\\s\\S]*?)<\\/lpk:${shortName}\\s*>`, 'g');
|
|
19
|
+
const newContent = processedContent.replace(regex, (fullMatch, attrs, children) => {
|
|
20
|
+
hasChanges = true;
|
|
21
|
+
importedComponents.add(componentNameStr);
|
|
22
|
+
return `<${componentNameStr}${attrs}>${children}</${componentNameStr}>`;
|
|
23
|
+
});
|
|
24
|
+
if (newContent !== processedContent) {
|
|
25
|
+
processedContent = newContent;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (processedContent === content)
|
|
30
|
+
return;
|
|
31
|
+
if (importedComponents.size > 0) {
|
|
32
|
+
const imports = Array.from(importedComponents).join(', ');
|
|
33
|
+
const scriptRegex = /<script(?![^>]*\bmodule\b)([^>]*)>/;
|
|
34
|
+
const scriptMatch = processedContent.match(scriptRegex);
|
|
35
|
+
if (scriptMatch && scriptMatch.index !== undefined) {
|
|
36
|
+
const insertPos = scriptMatch.index + scriptMatch[0].length;
|
|
37
|
+
processedContent =
|
|
38
|
+
processedContent.slice(0, insertPos) +
|
|
39
|
+
`\n\timport { ${imports} } from 'lapikit/labs/components';` +
|
|
40
|
+
processedContent.slice(insertPos);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const moduleScriptMatch = processedContent.match(/<script[^>]*\bmodule\b[^>]*>/);
|
|
44
|
+
if (moduleScriptMatch && moduleScriptMatch.index !== undefined) {
|
|
45
|
+
const moduleScriptEnd = processedContent.indexOf('</script>', moduleScriptMatch.index) + '</script>'.length;
|
|
46
|
+
processedContent =
|
|
47
|
+
processedContent.slice(0, moduleScriptEnd) +
|
|
48
|
+
`\n\n<script>\n\timport { ${imports} } from 'lapikit/labs/components';\n</script>` +
|
|
49
|
+
processedContent.slice(moduleScriptEnd);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
processedContent =
|
|
53
|
+
`<script>\n\timport { ${imports} } from 'lapikit/labs/components';\n</script>\n\n` +
|
|
54
|
+
processedContent;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
code: processedContent
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export { lapikitPreprocess };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { children, ...rest } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<button {...rest}>
|
|
6
|
+
{@render children()}
|
|
7
|
+
</button>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
button {
|
|
11
|
+
padding: 0.5em 1em;
|
|
12
|
+
border: none;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
background-color: #007bff;
|
|
15
|
+
color: white;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
font-size: 1em;
|
|
18
|
+
transition: background-color 0.3s ease;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
button:hover {
|
|
22
|
+
background-color: #0056b3;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lapikit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -75,6 +75,13 @@
|
|
|
75
75
|
"./themes": {
|
|
76
76
|
"types": "./dist/themes.css.d.ts",
|
|
77
77
|
"default": "./dist/themes.css"
|
|
78
|
+
},
|
|
79
|
+
"./labs/preprocess": {
|
|
80
|
+
"default": "./dist/entry-bundler.js"
|
|
81
|
+
},
|
|
82
|
+
"./labs/components": {
|
|
83
|
+
"svelte": "./dist/labs/components/index.js",
|
|
84
|
+
"default": "./dist/labs/components/index.js"
|
|
78
85
|
}
|
|
79
86
|
},
|
|
80
87
|
"peerDependencies": {
|
|
@@ -86,7 +93,7 @@
|
|
|
86
93
|
"@sveltejs/adapter-auto": "^4.0.0",
|
|
87
94
|
"@sveltejs/kit": "^2.16.0",
|
|
88
95
|
"@sveltejs/package": "^2.0.0",
|
|
89
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
96
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
90
97
|
"@testing-library/jest-dom": "^6.6.3",
|
|
91
98
|
"@testing-library/svelte": "^5.2.4",
|
|
92
99
|
"eslint": "^9.18.0",
|
|
@@ -101,7 +108,7 @@
|
|
|
101
108
|
"svelte-check": "^4.0.0",
|
|
102
109
|
"typescript": "^5.0.0",
|
|
103
110
|
"typescript-eslint": "^8.20.0",
|
|
104
|
-
"vite": "^
|
|
111
|
+
"vite": "^7.2.2",
|
|
105
112
|
"vitest": "^3.0.0"
|
|
106
113
|
},
|
|
107
114
|
"keywords": [
|