lapikit 0.0.0-insiders.09c4e21 → 0.0.0-insiders.0d42e81

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.
Files changed (60) hide show
  1. package/README.md +8 -8
  2. package/bin/index.js +1 -1
  3. package/dist/entry-bundler.d.ts +1 -3
  4. package/dist/entry-bundler.js +2 -104
  5. package/dist/internal/core/animations/ripple.js +5 -2
  6. package/dist/labs/animations/index.d.ts +1 -0
  7. package/dist/labs/animations/index.js +1 -0
  8. package/dist/labs/animations/ripple.d.ts +5 -0
  9. package/dist/labs/animations/ripple.js +96 -0
  10. package/dist/labs/assets/icon.svg +1 -0
  11. package/dist/labs/compiler/components.d.ts +2 -0
  12. package/dist/labs/compiler/components.js +10 -0
  13. package/dist/labs/compiler/index.d.ts +1 -0
  14. package/dist/labs/compiler/index.js +1 -0
  15. package/dist/labs/compiler/mapped-code.d.ts +1 -0
  16. package/dist/labs/compiler/mapped-code.js +52 -26
  17. package/dist/labs/compiler/plugins.d.ts +7 -0
  18. package/dist/labs/compiler/plugins.js +7 -0
  19. package/dist/labs/compiler/preprocess/decode-sourcemap.d.ts +2 -0
  20. package/dist/labs/compiler/preprocess/decode-sourcemap.js +106 -0
  21. package/dist/labs/compiler/preprocess/finding.d.ts +1 -0
  22. package/dist/labs/compiler/preprocess/finding.js +49 -0
  23. package/dist/labs/compiler/preprocess/index.d.ts +1 -0
  24. package/dist/labs/compiler/preprocess/index.js +1 -0
  25. package/dist/labs/compiler/preprocess/lili.d.ts +9 -0
  26. package/dist/labs/compiler/preprocess/lili.js +82 -0
  27. package/dist/labs/compiler/preprocess/source-import.d.ts +7 -0
  28. package/dist/labs/compiler/preprocess/source-import.js +9 -0
  29. package/dist/labs/compiler/types/index.d.ts +1 -0
  30. package/dist/labs/compiler/types/index.js +1 -1
  31. package/dist/labs/compiler/types/options.d.ts +12 -0
  32. package/dist/labs/compiler/types/options.js +1 -0
  33. package/dist/labs/components/app/app.svelte +146 -0
  34. package/dist/labs/components/app/app.svelte.d.ts +6 -0
  35. package/dist/labs/components/avatar/avatar.svelte +145 -0
  36. package/dist/labs/components/avatar/avatar.svelte.d.ts +4 -0
  37. package/dist/labs/components/avatar/avatar.types.d.ts +9 -0
  38. package/dist/labs/components/avatar/avatar.types.js +1 -0
  39. package/dist/labs/components/btn/btn.svelte +506 -12
  40. package/dist/labs/components/btn/btn.svelte.d.ts +2 -5
  41. package/dist/labs/components/btn/btn.types.d.ts +26 -0
  42. package/dist/labs/components/btn/btn.types.js +1 -0
  43. package/dist/labs/components/icon/icon.svelte +186 -0
  44. package/dist/labs/components/icon/icon.svelte.d.ts +4 -0
  45. package/dist/labs/components/icon/icon.types.d.ts +16 -0
  46. package/dist/labs/components/icon/icon.types.js +1 -0
  47. package/dist/labs/components/index.d.ts +6 -0
  48. package/dist/labs/components/index.js +6 -0
  49. package/dist/labs/components/list/list.svelte +190 -0
  50. package/dist/labs/components/list/list.svelte.d.ts +4 -0
  51. package/dist/labs/components/list/list.types.d.ts +30 -0
  52. package/dist/labs/components/list/list.types.js +1 -0
  53. package/dist/labs/components/list/modules/list-item.svelte +195 -0
  54. package/dist/labs/components/list/modules/list-item.svelte.d.ts +4 -0
  55. package/dist/labs/components/sheet/sheet.svelte +49 -0
  56. package/dist/labs/components/sheet/sheet.svelte.d.ts +7 -0
  57. package/dist/labs/utils/components.d.ts +5 -9
  58. package/dist/labs/utils/components.js +68 -62
  59. package/dist/labs/utils/types/index.d.ts +27 -0
  60. package/package.json +7 -4
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <a href="https://lapikit.dev">
2
- <img src="https://raw.githubusercontent.com/Nycolaide/lapikit/main/.github/lapikit.svg" alt="Lapikit Logo" width="125">
2
+ <img src="https://raw.githubusercontent.com/lapikit/lapikit.dev/main/.github/lapikit.svg" alt="Lapikit Logo" width="125">
3
3
  </a>
4
4
 
5
5
  # Lapikit - Svelte components library
@@ -8,10 +8,10 @@
8
8
  [![][subscribe-to-instagram]](https://www.instagram.com/lapikit/)
9
9
  [![][join-discord-lapikit]](https://discord.gg/gn9ZGtDtK4)
10
10
 
11
- [![][version]](https://github.com/nycolaide/lapikit/releases?q=lapikit&expanded=true)
11
+ [![][version]](https://github.com/lapikit/lapikit/releases?q=lapikit&expanded=true)
12
12
  [![][installs]](https://www.npmjs.com/package/lapikit)
13
13
  [![][installs-this-month]](https://www.npmjs.com/package/lapikit)
14
- [![][license]](https://github.com/nycolaide/lapikit/blob/main/LICENSE)
14
+ [![][license]](https://github.com/lapikit/lapikit/blob/main/LICENSE)
15
15
  [![][discord]](https://discord.gg/gn9ZGtDtK4)
16
16
 
17
17
  Lapikit is a comprehensive Svelte components library that provides developers with a wide range of pre-built, customizable UI components to streamline the development process. Whether you're building a simple website or a complex web application, Lapikit has the tools you need to create beautiful and functional user interfaces with ease.
@@ -71,7 +71,7 @@ Lapikit has created to help Svelte developers save time and effort when building
71
71
 
72
72
  ## 💖Community
73
73
 
74
- Join our growing community on [Discord](https://discord.gg/gn9ZGtDtK4) and [GitHub Discussions](https://github.com/nycolaide/lapikit/discussions) where we discuss and collaborate on all things Lapikit. Don't be shy, jump right in and be part of the discussion!
74
+ Join our growing community on [Discord](https://discord.gg/gn9ZGtDtK4) and [GitHub Discussions](https://github.com/lapikit/lapikit/discussions) where we discuss and collaborate on all things Lapikit. Don't be shy, jump right in and be part of the discussion!
75
75
 
76
76
  ## 💁‍♂️Contributing
77
77
 
@@ -84,7 +84,7 @@ Be part of the next revolution in code editing by contributing to the project. T
84
84
 
85
85
  ## 📄License
86
86
 
87
- Licensed under the [MIT license](https://github.com/nycolaide/lapikit/blob/main/LICENSE).
87
+ Licensed under the [MIT license](https://github.com/lapikit/lapikit/blob/main/LICENSE).
88
88
 
89
89
  Copyright © 2025 Nycolaide
90
90
 
@@ -96,12 +96,12 @@ We are proud supporters of the open-source community and contribute to several p
96
96
  <tr>
97
97
  <td>
98
98
  <a href="https://www.w3.org/">
99
- <img src="https://raw.githubusercontent.com/Nycolaide/lapikit/main/.github/w3c.svg" alt="W3C" width="75">
99
+ <img src="https://raw.githubusercontent.com/lapikit/lapikit.dev/main/.github/w3c.svg" alt="W3C" width="75">
100
100
  </a>
101
101
  </td>
102
102
  <td>
103
103
  <a href="https://humanstxt.org/">
104
- <img src="https://raw.githubusercontent.com/Nycolaide/lapikit/main/.github/humans.png" alt="Humans.txt" width="115">
104
+ <img src="https://raw.githubusercontent.com/lapikit/lapikit.dev/main/.github/humans.png" alt="Humans.txt" width="115">
105
105
  </a>
106
106
  </td>
107
107
  </tr>
@@ -111,7 +111,7 @@ We are proud supporters of the open-source community and contribute to several p
111
111
  [join-discord-lapikit]: https://img.shields.io/badge/Join%20the%20community-black.svg?style=for-the-badge&logo=Discord
112
112
  [subscribe-to-instagram]: https://img.shields.io/badge/Follow%20@Lapikit-black.svg?style=for-the-badge&logo=Instagram
113
113
  [version]: https://img.shields.io/npm/v/lapikit.svg?label=Version&color=f58142
114
- [license]: https://badgen.net/github/license/nycolaide/lapikit?label=License&color=cc5640
114
+ [license]: https://badgen.net/github/license/lapikit/lapikit?label=License&color=cc5640
115
115
  [installs]: https://badgen.net/npm/dt/lapikit?label=NPM%20installs&color=40ba12
116
116
  [installs-this-month]: https://badgen.net/npm/dm/lapikit?label=NPM%20installs&color=40ba12
117
117
  [discord]: https://img.shields.io/discord/1383879204671721492?color=5865F2&label=Discord&logo=discord&logoColor=white
package/bin/index.js CHANGED
@@ -23,7 +23,7 @@ async function run() {
23
23
  run()
24
24
  .then(() => {
25
25
  terminal('none', `\n\n\n\nWebsite: https://lapikit.dev`);
26
- terminal('none', `Github: https://github.com/nycolaide/lapikit`);
26
+ terminal('none', `Github: https://github.com/lapikit/lapikit`);
27
27
  terminal('none', `Support the developement: https://buymeacoffee.com/nycolaide`);
28
28
  process.exit(0);
29
29
  })
@@ -1,6 +1,4 @@
1
- type LapikitPreprocessOptions = {
2
- plugins?: string[];
3
- };
1
+ import type { LapikitPreprocessOptions } from './labs/compiler/types/options.js';
4
2
  declare function lapikitPreprocess(options?: LapikitPreprocessOptions): {
5
3
  markup({ content }: {
6
4
  content: string;
@@ -1,107 +1,5 @@
1
- const components = ['btn'];
2
- function componentName(shortName) {
3
- return 'Kit' + shortName.charAt(0).toUpperCase() + shortName.slice(1);
4
- }
5
- // plugins lapikit
6
- const lapikitPlugins = {
7
- repl: {
8
- components: ['repl'],
9
- ref: '@lapikit/repl'
10
- }
11
- };
1
+ import { liliCore } from './labs/compiler/preprocess/index.js';
12
2
  function lapikitPreprocess(options) {
13
- return {
14
- markup({ content }) {
15
- const allComponents = [...components];
16
- const componentToRef = new Map();
17
- components.forEach((comp) => {
18
- componentToRef.set(comp, 'lapikit/labs/components');
19
- });
20
- // plugins
21
- if (options?.plugins) {
22
- options.plugins.forEach((pluginKey) => {
23
- const plugin = lapikitPlugins[pluginKey];
24
- if (plugin) {
25
- plugin.components.forEach((comp) => {
26
- if (!allComponents.includes(comp)) {
27
- allComponents.push(comp);
28
- }
29
- componentToRef.set(comp, plugin.ref);
30
- });
31
- }
32
- });
33
- }
34
- const hasComponent = allComponents.some((comp) => content.includes(`<kit:${comp}`));
35
- if (!hasComponent)
36
- return;
37
- let processedContent = content;
38
- const importedComponents = new Map();
39
- let hasChanges = true;
40
- while (hasChanges) {
41
- hasChanges = false;
42
- for (const shortName of allComponents) {
43
- const componentNameStr = componentName(shortName);
44
- const attrPattern = `(?:[^>"']|"[^"]*"|'[^']*')*?`;
45
- const selfClosingRegex = new RegExp(`<kit:${shortName}(${attrPattern})\\s*/>`, 'g');
46
- const pairRegex = new RegExp(`<kit:${shortName}(${attrPattern})>([\\s\\S]*?)<\\/kit:${shortName}\\s*>`, 'g');
47
- let newContent = processedContent.replace(selfClosingRegex, (fullMatch, attrs) => {
48
- hasChanges = true;
49
- const ref = componentToRef.get(shortName) || 'lapikit/labs/components';
50
- importedComponents.set(componentNameStr, ref);
51
- return `<${componentNameStr}${attrs} />`;
52
- });
53
- newContent = newContent.replace(pairRegex, (fullMatch, attrs, children) => {
54
- hasChanges = true;
55
- const ref = componentToRef.get(shortName) || 'lapikit/labs/components';
56
- importedComponents.set(componentNameStr, ref);
57
- return `<${componentNameStr}${attrs}>${children}</${componentNameStr}>`;
58
- });
59
- if (newContent !== processedContent) {
60
- processedContent = newContent;
61
- }
62
- }
63
- }
64
- if (processedContent === content)
65
- return;
66
- if (importedComponents.size > 0) {
67
- const importsByRef = new Map();
68
- importedComponents.forEach((ref, component) => {
69
- if (!importsByRef.has(ref)) {
70
- importsByRef.set(ref, []);
71
- }
72
- importsByRef.get(ref).push(component);
73
- });
74
- const importLines = Array.from(importsByRef.entries())
75
- .map(([ref, components]) => {
76
- const imports = components.join(', ');
77
- return `\n\timport { ${imports} } from '${ref}';`;
78
- })
79
- .join('');
80
- const scriptRegex = /<script(?![^>]*\bmodule\b)([^>]*)>/;
81
- const scriptMatch = processedContent.match(scriptRegex);
82
- if (scriptMatch && scriptMatch.index !== undefined) {
83
- const insertPos = scriptMatch.index + scriptMatch[0].length;
84
- processedContent =
85
- processedContent.slice(0, insertPos) + importLines + processedContent.slice(insertPos);
86
- }
87
- else {
88
- const moduleScriptMatch = processedContent.match(/<script[^>]*\bmodule\b[^>]*>/);
89
- if (moduleScriptMatch && moduleScriptMatch.index !== undefined) {
90
- const moduleScriptEnd = processedContent.indexOf('</script>', moduleScriptMatch.index) + '</script>'.length;
91
- processedContent =
92
- processedContent.slice(0, moduleScriptEnd) +
93
- `\n\n<script>${importLines}\n</script>` +
94
- processedContent.slice(moduleScriptEnd);
95
- }
96
- else {
97
- processedContent = `<script>${importLines}\n</script>\n\n` + processedContent;
98
- }
99
- }
100
- }
101
- return {
102
- code: processedContent
103
- };
104
- }
105
- };
3
+ return liliCore(options);
106
4
  }
107
5
  export { lapikitPreprocess };
@@ -4,6 +4,9 @@ export function ripple(el, options = {}) {
4
4
  const rippleContainer = document.createElement('div');
5
5
  addClasses();
6
6
  setOptions(options);
7
+ function isAriaDisabled() {
8
+ return el.getAttribute('aria-disabled') === 'true';
9
+ }
7
10
  function addClasses(center) {
8
11
  const shouldBeCentered = center || options.center;
9
12
  if (!rippleContainer.classList.contains('kit-ripple--effect')) {
@@ -17,7 +20,7 @@ export function ripple(el, options = {}) {
17
20
  }
18
21
  }
19
22
  function setOptions(options) {
20
- if (options.disabled || el.hasAttribute('aria-disabled')) {
23
+ if (options.disabled || isAriaDisabled()) {
21
24
  rippleContainer.remove();
22
25
  }
23
26
  else {
@@ -37,7 +40,7 @@ export function ripple(el, options = {}) {
37
40
  }
38
41
  }
39
42
  function createRipple(e, center) {
40
- if (options.disabled || el.hasAttribute('aria-disabled')) {
43
+ if (options.disabled || isAriaDisabled()) {
41
44
  return;
42
45
  }
43
46
  if (e instanceof KeyboardEvent) {
@@ -0,0 +1 @@
1
+ export * from './ripple.ts';
@@ -0,0 +1 @@
1
+ export * from "./ripple.js";
@@ -0,0 +1,5 @@
1
+ import type { RippleProps } from '../utils/types/index.ts';
2
+ export declare function ripple(el: HTMLElement, options?: RippleProps): {
3
+ destroy(): void;
4
+ update(newOptions: RippleProps): void;
5
+ };
@@ -0,0 +1,96 @@
1
+ const triggerEvents = ['pointerdown', 'touchstart', 'keydown'];
2
+ const cancelEvents = ['mouseleave', 'dragleave', 'touchmove', 'touchcancel', 'pointerup', 'keyup'];
3
+ export function ripple(el, options = {}) {
4
+ const rippleContainer = document.createElement('div');
5
+ addClasses();
6
+ setOptions(options);
7
+ function isAriaDisabled() {
8
+ return el.getAttribute('aria-disabled') === 'true';
9
+ }
10
+ function addClasses(center) {
11
+ const shouldBeCentered = center || options.center;
12
+ if (!rippleContainer.classList.contains('kit-ripple--effect')) {
13
+ rippleContainer.classList.add('kit-ripple--effect');
14
+ }
15
+ if (!shouldBeCentered && rippleContainer.classList.contains('kit-ripple--center')) {
16
+ rippleContainer.classList.remove('kit-ripple--center');
17
+ }
18
+ if (shouldBeCentered) {
19
+ rippleContainer.classList.add('kit-ripple--center');
20
+ }
21
+ }
22
+ function setOptions(options) {
23
+ if (options.disabled || isAriaDisabled()) {
24
+ rippleContainer.remove();
25
+ }
26
+ else {
27
+ el.appendChild(rippleContainer);
28
+ }
29
+ if (options.duration && options.duration < 0) {
30
+ options.duration = undefined;
31
+ }
32
+ if (options.component) {
33
+ rippleContainer.style.setProperty('--system-ripple-radius', `var(--${options.component}-shape)`);
34
+ }
35
+ if (options.color) {
36
+ rippleContainer.style.setProperty('--system-ripple-color', options.color);
37
+ }
38
+ if (options.duration) {
39
+ rippleContainer.style.setProperty('--system-animation-ripple-duration', `${options.duration}ms`);
40
+ }
41
+ }
42
+ function createRipple(e, center) {
43
+ if (options.disabled || isAriaDisabled()) {
44
+ return;
45
+ }
46
+ if (e instanceof KeyboardEvent) {
47
+ if (!['Enter', 'Space'].includes(e.code) || e.repeat) {
48
+ return;
49
+ }
50
+ e.preventDefault();
51
+ const click = new PointerEvent('pointerdown');
52
+ createRipple(click, true);
53
+ return;
54
+ }
55
+ addClasses(center);
56
+ const rect = el.getBoundingClientRect();
57
+ const clientX = window.TouchEvent && e instanceof TouchEvent
58
+ ? e.touches[0].clientX
59
+ : e.clientX;
60
+ const clientY = window.TouchEvent && e instanceof TouchEvent
61
+ ? e.touches[0].clientY
62
+ : e.clientY;
63
+ const x = clientX - rect.left > el.offsetWidth / 2 ? 0 : el.offsetWidth;
64
+ const y = clientY - rect.top > el.offsetHeight / 2 ? 0 : el.offsetHeight;
65
+ const radius = Math.hypot(x - (clientX - rect.left), y - (clientY - rect.top));
66
+ const ripple = document.createElement('div');
67
+ ripple.classList.add('kit-ripple');
68
+ ripple.style.left = `${clientX - rect.left - radius}px`;
69
+ ripple.style.top = `${clientY - rect.top - radius}px`;
70
+ ripple.style.width = ripple.style.height = `${radius * 2}px`;
71
+ rippleContainer.appendChild(ripple);
72
+ function removeRipple() {
73
+ if (ripple === null) {
74
+ return;
75
+ }
76
+ ripple.style.opacity = '0';
77
+ setTimeout(() => {
78
+ ripple.remove();
79
+ }, options.duration || 1000);
80
+ cancelEvents.forEach((event) => el.removeEventListener(event, removeRipple));
81
+ }
82
+ cancelEvents.forEach((event) => el.addEventListener(event, removeRipple, { passive: true }));
83
+ }
84
+ triggerEvents.forEach((event) => el.addEventListener(event, createRipple, { passive: event === 'touchstart' }));
85
+ return {
86
+ destroy() {
87
+ triggerEvents.forEach((event) => {
88
+ el.removeEventListener(event, createRipple);
89
+ });
90
+ },
91
+ update(newOptions) {
92
+ options = newOptions;
93
+ setOptions(newOptions);
94
+ }
95
+ };
96
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-align-end-horizontal-icon lucide-align-end-horizontal"><rect width="6" height="16" x="4" y="2" rx="2"/><rect width="6" height="9" x="14" y="9" rx="2"/><path d="M22 22H2"/></svg>
@@ -0,0 +1,2 @@
1
+ declare const lapikitComponents: readonly string[];
2
+ export default lapikitComponents;
@@ -0,0 +1,10 @@
1
+ const lapikitComponents = [
2
+ 'sheet',
3
+ 'app',
4
+ 'btn',
5
+ 'icon',
6
+ 'avatar',
7
+ 'list',
8
+ 'list-item'
9
+ ];
10
+ export default lapikitComponents;
@@ -0,0 +1 @@
1
+ export * from './preprocess/index.js';
@@ -0,0 +1 @@
1
+ export * from './preprocess/index.js';
@@ -16,6 +16,7 @@ export declare function computeSClasses(sClass: SClassProp, classDirectiveProps:
16
16
  export declare function computeSStyles(sStyle: SStyleProp, styleDirectiveProps: Record<string, unknown>): string;
17
17
  /**
18
18
  * Makes component props by separating s-class and s-style directives from other props.
19
+ * Optimized to use a single pass instead of three separate iterations.
19
20
  * @param props The original props object containing all props.
20
21
  * @returns An object containing separated classProps, styleProps, and restProps.
21
22
  */
@@ -20,25 +20,32 @@ export function computeSClasses(sClass, classDirectiveProps) {
20
20
  }
21
21
  // s-class object
22
22
  if (sClass && typeof sClass === 'object' && !Array.isArray(sClass)) {
23
- Object.entries(sClass).forEach(([key, value]) => {
23
+ const entries = Object.entries(sClass);
24
+ if (entries.length > 0) {
25
+ for (const [key, value] of entries) {
26
+ if (value === true) {
27
+ classes.push(key);
28
+ }
29
+ else if (typeof value === 'string' && value) {
30
+ classes.push(value);
31
+ }
32
+ }
33
+ }
34
+ }
35
+ // s-class_xxx
36
+ const classEntries = Object.entries(classDirectiveProps);
37
+ if (classEntries.length > 0) {
38
+ for (const [key, value] of classEntries) {
39
+ // Use slice instead of replace for better performance (8 = 's-class_'.length)
40
+ const base = key.slice(8);
24
41
  if (value === true) {
25
- classes.push(key);
42
+ classes.push(base);
26
43
  }
27
44
  else if (typeof value === 'string' && value) {
28
- classes.push(value);
45
+ classes.push(`${base}${value}`);
29
46
  }
30
- });
31
- }
32
- // s-class_xxx
33
- Object.entries(classDirectiveProps).forEach(([key, value]) => {
34
- const base = key.replace('s-class_', '');
35
- if (value === true) {
36
- classes.push(base);
37
47
  }
38
- else if (typeof value === 'string' && value) {
39
- classes.push(`${base}${value}`);
40
- }
41
- });
48
+ }
42
49
  return classes.join(' ');
43
50
  }
44
51
  /**
@@ -50,28 +57,47 @@ export function computeSClasses(sClass, classDirectiveProps) {
50
57
  export function computeSStyles(sStyle, styleDirectiveProps) {
51
58
  const styles = [];
52
59
  if (sStyle && typeof sStyle === 'object') {
53
- Object.entries(sStyle).forEach(([key, value]) => {
54
- if (value) {
55
- styles.push(`${key}: ${value}`);
60
+ const entries = Object.entries(sStyle);
61
+ if (entries.length > 0) {
62
+ for (const [key, value] of entries) {
63
+ if (value) {
64
+ styles.push(`${key}: ${value}`);
65
+ }
56
66
  }
57
- });
67
+ }
58
68
  }
59
- Object.entries(styleDirectiveProps).forEach(([key, value]) => {
60
- const base = key.replace('s-style_', '');
61
- if (value) {
62
- styles.push(`${base}: ${value}`);
69
+ const styleEntries = Object.entries(styleDirectiveProps);
70
+ if (styleEntries.length > 0) {
71
+ for (const [key, value] of styleEntries) {
72
+ // Use slice instead of replace for better performance (8 = 's-style_'.length)
73
+ const base = key.slice(8);
74
+ if (value) {
75
+ styles.push(`${base}: ${value}`);
76
+ }
63
77
  }
64
- });
78
+ }
65
79
  return styles.join('; ');
66
80
  }
67
81
  /**
68
82
  * Makes component props by separating s-class and s-style directives from other props.
83
+ * Optimized to use a single pass instead of three separate iterations.
69
84
  * @param props The original props object containing all props.
70
85
  * @returns An object containing separated classProps, styleProps, and restProps.
71
86
  */
72
87
  export function makeComponentProps(props) {
73
- const classProps = Object.fromEntries(Object.entries(props).filter(([key]) => key.startsWith('s-class_')));
74
- const styleProps = Object.fromEntries(Object.entries(props).filter(([key]) => key.startsWith('s-style_')));
75
- const restProps = Object.fromEntries(Object.entries(props).filter(([key]) => !key.startsWith('s-class') && !key.startsWith('s-style')));
88
+ const classProps = {};
89
+ const styleProps = {};
90
+ const restProps = {};
91
+ for (const [key, value] of Object.entries(props)) {
92
+ if (key.startsWith('s-class_')) {
93
+ classProps[key] = value;
94
+ }
95
+ else if (key.startsWith('s-style_')) {
96
+ styleProps[key] = value;
97
+ }
98
+ else if (!key.startsWith('s-class') && !key.startsWith('s-style')) {
99
+ restProps[key] = value;
100
+ }
101
+ }
76
102
  return { classProps, styleProps, restProps };
77
103
  }
@@ -0,0 +1,7 @@
1
+ declare const lapikitPlugins: {
2
+ readonly repl: {
3
+ readonly components: readonly ["repl"];
4
+ readonly ref: "@lapikit/repl";
5
+ };
6
+ };
7
+ export default lapikitPlugins;
@@ -0,0 +1,7 @@
1
+ const lapikitPlugins = {
2
+ repl: {
3
+ components: ['repl'],
4
+ ref: '@lapikit/repl'
5
+ }
6
+ };
7
+ export default lapikitPlugins;
@@ -0,0 +1,2 @@
1
+ import type { ComponentInfo, KitComponentScan } from '../types/index.js';
2
+ export declare const decodeSourceMap: (content: string, componentInfo: Map<string, ComponentInfo>) => KitComponentScan;
@@ -0,0 +1,106 @@
1
+ import { findTagEnd } from './finding.js';
2
+ export const decodeSourceMap = (content, componentInfo) => {
3
+ const importedComponents = new Map();
4
+ const parts = [];
5
+ let changed = false;
6
+ let index = 0;
7
+ const length = content.length;
8
+ while (index < length) {
9
+ const nextLt = content.indexOf('<', index);
10
+ if (nextLt === -1) {
11
+ parts.push(content.slice(index));
12
+ break;
13
+ }
14
+ if (nextLt > index) {
15
+ parts.push(content.slice(index, nextLt));
16
+ }
17
+ const ch = content[nextLt + 1];
18
+ const isClosing = ch === '/';
19
+ if (content.startsWith('<script', nextLt) || content.startsWith('<style', nextLt)) {
20
+ const tagName = content.startsWith('<script', nextLt) ? 'script' : 'style';
21
+ const nameEnd = nextLt + tagName.length + 1;
22
+ const afterName = content[nameEnd];
23
+ if (afterName && !/[\s>/]/.test(afterName)) {
24
+ parts.push('<');
25
+ index = nextLt + 1;
26
+ continue;
27
+ }
28
+ const openEnd = findTagEnd(content, nameEnd);
29
+ if (openEnd === -1) {
30
+ parts.push(content.slice(nextLt));
31
+ break;
32
+ }
33
+ const closeTag = `</${tagName}>`;
34
+ const closeStart = content.indexOf(closeTag, openEnd + 1);
35
+ if (closeStart === -1) {
36
+ parts.push(content.slice(nextLt));
37
+ break;
38
+ }
39
+ const closeEnd = closeStart + closeTag.length;
40
+ parts.push(content.slice(nextLt, closeEnd));
41
+ index = closeEnd;
42
+ continue;
43
+ }
44
+ const isKitTag = (!isClosing && content.startsWith('<kit:', nextLt)) ||
45
+ (isClosing && content.startsWith('</kit:', nextLt));
46
+ if (!isKitTag) {
47
+ parts.push('<');
48
+ index = nextLt + 1;
49
+ continue;
50
+ }
51
+ const prefixLength = isClosing ? 6 : 5;
52
+ const nameStart = nextLt + prefixLength;
53
+ let nameEnd = nameStart;
54
+ while (nameEnd < length) {
55
+ const c = content[nameEnd];
56
+ if (c === '>' || c === '/' || c === ' ' || c === '\n' || c === '\t' || c === '\r') {
57
+ break;
58
+ }
59
+ nameEnd++;
60
+ }
61
+ const shortName = content.slice(nameStart, nameEnd);
62
+ if (!shortName) {
63
+ parts.push('<');
64
+ index = nextLt + 1;
65
+ continue;
66
+ }
67
+ const info = componentInfo.get(shortName);
68
+ const isKnown = info !== undefined;
69
+ if (isClosing) {
70
+ const tagEnd = content.indexOf('>', nameEnd);
71
+ if (tagEnd === -1) {
72
+ parts.push(content.slice(nextLt));
73
+ break;
74
+ }
75
+ if (isKnown) {
76
+ importedComponents.set(info.name, info.ref);
77
+ parts.push(`</${info.name}>`);
78
+ changed = true;
79
+ }
80
+ else {
81
+ parts.push(content.slice(nextLt, tagEnd + 1));
82
+ }
83
+ index = tagEnd + 1;
84
+ continue;
85
+ }
86
+ const tagEnd = findTagEnd(content, nameEnd);
87
+ if (tagEnd === -1) {
88
+ parts.push(content.slice(nextLt));
89
+ break;
90
+ }
91
+ if (isKnown) {
92
+ importedComponents.set(info.name, info.ref);
93
+ parts.push(`<${info.name}${content.slice(nameEnd, tagEnd + 1)}`);
94
+ changed = true;
95
+ }
96
+ else {
97
+ parts.push(content.slice(nextLt, tagEnd + 1));
98
+ }
99
+ index = tagEnd + 1;
100
+ }
101
+ return {
102
+ code: changed ? parts.join('') : content,
103
+ changed,
104
+ importedComponents
105
+ };
106
+ };
@@ -0,0 +1 @@
1
+ export declare const findTagEnd: (content: string, start: number) => number;
@@ -0,0 +1,49 @@
1
+ export const findTagEnd = (content, start) => {
2
+ let inSingle = false;
3
+ let inDouble = false;
4
+ let inTemplate = false;
5
+ let braceDepth = 0;
6
+ for (let i = start; i < content.length; i++) {
7
+ const ch = content[i];
8
+ const prev = i > 0 ? content[i - 1] : '';
9
+ if (inSingle) {
10
+ if (ch === "'" && prev !== '\\')
11
+ inSingle = false;
12
+ continue;
13
+ }
14
+ if (inDouble) {
15
+ if (ch === '"' && prev !== '\\')
16
+ inDouble = false;
17
+ continue;
18
+ }
19
+ if (inTemplate) {
20
+ if (ch === '`' && prev !== '\\')
21
+ inTemplate = false;
22
+ continue;
23
+ }
24
+ if (ch === "'") {
25
+ inSingle = true;
26
+ continue;
27
+ }
28
+ if (ch === '"') {
29
+ inDouble = true;
30
+ continue;
31
+ }
32
+ if (ch === '`') {
33
+ inTemplate = true;
34
+ continue;
35
+ }
36
+ if (ch === '{') {
37
+ braceDepth++;
38
+ continue;
39
+ }
40
+ if (ch === '}' && braceDepth > 0) {
41
+ braceDepth--;
42
+ continue;
43
+ }
44
+ if (braceDepth === 0 && ch === '>') {
45
+ return i;
46
+ }
47
+ }
48
+ return -1;
49
+ };
@@ -0,0 +1 @@
1
+ export * from './lili.js';
@@ -0,0 +1 @@
1
+ export * from './lili.js';