@fukict/basic 0.1.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.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/dist/component-class/fukict.d.ts +207 -0
  3. package/dist/component-class/fukict.d.ts.map +1 -0
  4. package/dist/component-class/fukict.js +299 -0
  5. package/dist/component-class/fukict.js.map +1 -0
  6. package/dist/component-class/index.d.ts +5 -0
  7. package/dist/component-class/index.d.ts.map +1 -0
  8. package/dist/component-class/index.js +5 -0
  9. package/dist/component-class/index.js.map +1 -0
  10. package/dist/component-class/slot.d.ts +9 -0
  11. package/dist/component-class/slot.d.ts.map +1 -0
  12. package/dist/component-class/slot.js +46 -0
  13. package/dist/component-class/slot.js.map +1 -0
  14. package/dist/component-function/define.d.ts +36 -0
  15. package/dist/component-function/define.d.ts.map +1 -0
  16. package/dist/component-function/define.js +23 -0
  17. package/dist/component-function/define.js.map +1 -0
  18. package/dist/component-function/index.d.ts +6 -0
  19. package/dist/component-function/index.d.ts.map +1 -0
  20. package/dist/component-function/index.js +5 -0
  21. package/dist/component-function/index.js.map +1 -0
  22. package/dist/dom/attributes.d.ts +36 -0
  23. package/dist/dom/attributes.d.ts.map +1 -0
  24. package/dist/dom/attributes.js +113 -0
  25. package/dist/dom/attributes.js.map +1 -0
  26. package/dist/dom/element.d.ts +22 -0
  27. package/dist/dom/element.d.ts.map +1 -0
  28. package/dist/dom/element.js +98 -0
  29. package/dist/dom/element.js.map +1 -0
  30. package/dist/dom/events.d.ts +14 -0
  31. package/dist/dom/events.d.ts.map +1 -0
  32. package/dist/dom/events.js +18 -0
  33. package/dist/dom/events.js.map +1 -0
  34. package/dist/dom/index.d.ts +10 -0
  35. package/dist/dom/index.d.ts.map +1 -0
  36. package/dist/dom/index.js +14 -0
  37. package/dist/dom/index.js.map +1 -0
  38. package/dist/dom/node.d.ts +22 -0
  39. package/dist/dom/node.d.ts.map +1 -0
  40. package/dist/dom/node.js +30 -0
  41. package/dist/dom/node.js.map +1 -0
  42. package/dist/index.d.ts +22 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +26 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/jsx-runtime.d.ts +10 -0
  47. package/dist/jsx-runtime.d.ts.map +1 -0
  48. package/dist/jsx-runtime.js +9 -0
  49. package/dist/jsx-runtime.js.map +1 -0
  50. package/dist/metadata.d.ts +14 -0
  51. package/dist/metadata.d.ts.map +1 -0
  52. package/dist/metadata.js +14 -0
  53. package/dist/metadata.js.map +1 -0
  54. package/dist/renderer/attributes.d.ts +15 -0
  55. package/dist/renderer/attributes.d.ts.map +1 -0
  56. package/dist/renderer/attributes.js +61 -0
  57. package/dist/renderer/attributes.js.map +1 -0
  58. package/dist/renderer/create.d.ts +30 -0
  59. package/dist/renderer/create.d.ts.map +1 -0
  60. package/dist/renderer/create.js +223 -0
  61. package/dist/renderer/create.js.map +1 -0
  62. package/dist/renderer/diff/children.d.ts +12 -0
  63. package/dist/renderer/diff/children.d.ts.map +1 -0
  64. package/dist/renderer/diff/children.js +55 -0
  65. package/dist/renderer/diff/children.js.map +1 -0
  66. package/dist/renderer/diff/class.d.ts +8 -0
  67. package/dist/renderer/diff/class.d.ts.map +1 -0
  68. package/dist/renderer/diff/class.js +38 -0
  69. package/dist/renderer/diff/class.js.map +1 -0
  70. package/dist/renderer/diff/element.d.ts +14 -0
  71. package/dist/renderer/diff/element.d.ts.map +1 -0
  72. package/dist/renderer/diff/element.js +34 -0
  73. package/dist/renderer/diff/element.js.map +1 -0
  74. package/dist/renderer/diff/fragment.d.ts +13 -0
  75. package/dist/renderer/diff/fragment.d.ts.map +1 -0
  76. package/dist/renderer/diff/fragment.js +32 -0
  77. package/dist/renderer/diff/fragment.js.map +1 -0
  78. package/dist/renderer/diff/function.d.ts +9 -0
  79. package/dist/renderer/diff/function.d.ts.map +1 -0
  80. package/dist/renderer/diff/function.js +58 -0
  81. package/dist/renderer/diff/function.js.map +1 -0
  82. package/dist/renderer/diff/helpers.d.ts +19 -0
  83. package/dist/renderer/diff/helpers.d.ts.map +1 -0
  84. package/dist/renderer/diff/helpers.js +194 -0
  85. package/dist/renderer/diff/helpers.js.map +1 -0
  86. package/dist/renderer/diff/index.d.ts +18 -0
  87. package/dist/renderer/diff/index.d.ts.map +1 -0
  88. package/dist/renderer/diff/index.js +103 -0
  89. package/dist/renderer/diff/index.js.map +1 -0
  90. package/dist/renderer/diff/props.d.ts +18 -0
  91. package/dist/renderer/diff/props.d.ts.map +1 -0
  92. package/dist/renderer/diff/props.js +99 -0
  93. package/dist/renderer/diff/props.js.map +1 -0
  94. package/dist/renderer/index.d.ts +26 -0
  95. package/dist/renderer/index.d.ts.map +1 -0
  96. package/dist/renderer/index.js +93 -0
  97. package/dist/renderer/index.js.map +1 -0
  98. package/dist/renderer/mount.d.ts +30 -0
  99. package/dist/renderer/mount.d.ts.map +1 -0
  100. package/dist/renderer/mount.js +209 -0
  101. package/dist/renderer/mount.js.map +1 -0
  102. package/dist/types/class.d.ts +88 -0
  103. package/dist/types/class.d.ts.map +1 -0
  104. package/dist/types/class.js +2 -0
  105. package/dist/types/class.js.map +1 -0
  106. package/dist/types/context.d.ts +36 -0
  107. package/dist/types/context.d.ts.map +1 -0
  108. package/dist/types/context.js +9 -0
  109. package/dist/types/context.js.map +1 -0
  110. package/dist/types/core.d.ts +124 -0
  111. package/dist/types/core.d.ts.map +1 -0
  112. package/dist/types/core.js +15 -0
  113. package/dist/types/core.js.map +1 -0
  114. package/dist/types/dom-attributes.d.ts +236 -0
  115. package/dist/types/dom-attributes.d.ts.map +1 -0
  116. package/dist/types/dom-attributes.js +2 -0
  117. package/dist/types/dom-attributes.js.map +1 -0
  118. package/dist/types/events.d.ts +13 -0
  119. package/dist/types/events.d.ts.map +1 -0
  120. package/dist/types/events.js +7 -0
  121. package/dist/types/events.js.map +1 -0
  122. package/dist/types/index.d.ts +12 -0
  123. package/dist/types/index.d.ts.map +1 -0
  124. package/dist/types/index.js +7 -0
  125. package/dist/types/index.js.map +1 -0
  126. package/dist/types/jsx.d.ts +215 -0
  127. package/dist/types/jsx.d.ts.map +1 -0
  128. package/dist/types/jsx.js +2 -0
  129. package/dist/types/jsx.js.map +1 -0
  130. package/dist/utils/context.d.ts +31 -0
  131. package/dist/utils/context.d.ts.map +1 -0
  132. package/dist/utils/context.js +80 -0
  133. package/dist/utils/context.js.map +1 -0
  134. package/dist/utils/dom-helpers.d.ts +29 -0
  135. package/dist/utils/dom-helpers.d.ts.map +1 -0
  136. package/dist/utils/dom-helpers.js +53 -0
  137. package/dist/utils/dom-helpers.js.map +1 -0
  138. package/dist/vnode.d.ts +28 -0
  139. package/dist/vnode.d.ts.map +1 -0
  140. package/dist/vnode.js +68 -0
  141. package/dist/vnode.js.map +1 -0
  142. package/package.json +61 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Create immutable proxy for context values
3
+ *
4
+ * Prevents child components from mutating context values,
5
+ * ensuring unidirectional data flow.
6
+ *
7
+ * **Important**: Proxy only prevents mutation, it does NOT trigger updates.
8
+ * Context updates must be explicit:
9
+ * 1. Call provideContext() to replace the context value
10
+ * 2. Call this.update() to trigger re-rendering
11
+ * 3. Child components get new value via getContext() during render
12
+ *
13
+ * @param value - Context value to wrap
14
+ * @returns Proxied immutable value
15
+ * @internal
16
+ */
17
+ export function createImmutableProxy(value) {
18
+ // Primitive values don't need proxy
19
+ if (typeof value !== 'object' || value === null) {
20
+ return value;
21
+ }
22
+ return new Proxy(value, {
23
+ set() {
24
+ console.warn('[Fukict] Context values are immutable and cannot be modified');
25
+ return false; // Block modification, but does NOT trigger update
26
+ },
27
+ deleteProperty() {
28
+ console.warn('[Fukict] Context values are immutable and cannot be modified');
29
+ return false;
30
+ },
31
+ get(target, prop) {
32
+ const result = Reflect.get(target, prop);
33
+ // Deep proxy for nested objects
34
+ if (typeof result === 'object' && result !== null) {
35
+ return createImmutableProxy(result);
36
+ }
37
+ return result;
38
+ },
39
+ });
40
+ }
41
+ /**
42
+ * Get parent context from VNode
43
+ *
44
+ * Traverses up the wrapper VNode tree to find nearest parent component with context.
45
+ * The wrapper VNode is the ClassComponentVNode that wraps a component instance.
46
+ *
47
+ * @param vnode - Current VNode (unused, we traverse via __wrapper__ on instance)
48
+ * @returns Parent context data or undefined
49
+ * @internal
50
+ */
51
+ export function getParentContext(vnode) {
52
+ // Get instance from ClassComponentVNode
53
+ const vnodeWithInstance = vnode;
54
+ const instance = vnodeWithInstance.__instance__;
55
+ if (!instance) {
56
+ return undefined;
57
+ }
58
+ // Get wrapper VNode (the ClassComponentVNode that wraps this instance)
59
+ const wrapper = instance.__wrapper__;
60
+ if (!wrapper || !wrapper.props) {
61
+ return undefined;
62
+ }
63
+ // Look for parent context by traversing up the VNode tree
64
+ // We need to find the parent component that rendered this wrapper VNode
65
+ // This requires walking through the children arrays to find parent relationship
66
+ // For now, implement a simpler approach:
67
+ // Look for context in parent by checking if wrapper has __parentInstance__
68
+ // This will be set during rendering
69
+ // Alternative: Search through all active component instances
70
+ // But this violates the "no global state" principle
71
+ // The correct approach: During render, when parent creates child VNode,
72
+ // we should store parent instance reference on the child's wrapper VNode
73
+ // Let's add __parentInstance__ field during createRealNode
74
+ const parentInstance = instance.__parentInstance__;
75
+ if (parentInstance && parentInstance.__vnode__) {
76
+ return parentInstance.__vnode__.__context__;
77
+ }
78
+ return undefined;
79
+ }
80
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/utils/context.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAAI,KAAQ;IAC9C,oCAAoC;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,KAAK,CAAC,KAAe,EAAE;QAChC,GAAG;YACD,OAAO,CAAC,IA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AED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fukict/basic - DOM Helper Utilities
3
+ *
4
+ * Helper functions for working with DOM references in VNodes
5
+ */
6
+ import type { VNode } from '../types/index.js';
7
+ /**
8
+ * Check if __dom__ is an array (Fragment or multi-node)
9
+ */
10
+ export declare function isDomArray(dom: unknown): dom is Node[];
11
+ /**
12
+ * Normalize __dom__ to array (for unified processing)
13
+ */
14
+ export declare function normalizeDom(dom: Node | Node[] | null | undefined): Node[];
15
+ /**
16
+ * Get first DOM node from VNode
17
+ * Returns null for class components (they don't have __dom__)
18
+ */
19
+ export declare function getFirstDomNode(vnode: VNode): Node | null;
20
+ /**
21
+ * Get all DOM nodes from VNode
22
+ * Returns empty array for class components
23
+ */
24
+ export declare function getAllDomNodes(vnode: VNode): Node[];
25
+ /**
26
+ * Check if vnode is a valid VNode object
27
+ */
28
+ export declare function isVNode(value: unknown): value is VNode;
29
+ //# sourceMappingURL=dom-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/dom-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI,EAAE,CAEtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,EAAE,CAI1E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAczD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,CAQnD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEtD"}
@@ -0,0 +1,53 @@
1
+ import { VNodeType } from '../types/index.js';
2
+ /**
3
+ * Check if __dom__ is an array (Fragment or multi-node)
4
+ */
5
+ export function isDomArray(dom) {
6
+ return Array.isArray(dom);
7
+ }
8
+ /**
9
+ * Normalize __dom__ to array (for unified processing)
10
+ */
11
+ export function normalizeDom(dom) {
12
+ if (!dom)
13
+ return [];
14
+ if (Array.isArray(dom))
15
+ return dom;
16
+ return [dom];
17
+ }
18
+ /**
19
+ * Get first DOM node from VNode
20
+ * Returns null for class components (they don't have __dom__)
21
+ */
22
+ export function getFirstDomNode(vnode) {
23
+ // Class components don't have __dom__
24
+ if (vnode.__type__ === VNodeType.ClassComponent) {
25
+ return null;
26
+ }
27
+ const dom = '__dom__' in vnode ? vnode.__dom__ : null;
28
+ if (!dom)
29
+ return null;
30
+ if (Array.isArray(dom)) {
31
+ return dom[0] || null;
32
+ }
33
+ return dom;
34
+ }
35
+ /**
36
+ * Get all DOM nodes from VNode
37
+ * Returns empty array for class components
38
+ */
39
+ export function getAllDomNodes(vnode) {
40
+ // Class components don't have __dom__
41
+ if (vnode.__type__ === VNodeType.ClassComponent) {
42
+ return [];
43
+ }
44
+ const dom = '__dom__' in vnode ? vnode.__dom__ : null;
45
+ return normalizeDom(dom);
46
+ }
47
+ /**
48
+ * Check if vnode is a valid VNode object
49
+ */
50
+ export function isVNode(value) {
51
+ return typeof value === 'object' && value !== null && '__type__' in value;
52
+ }
53
+ //# sourceMappingURL=dom-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-helpers.js","sourceRoot":"","sources":["../../src/utils/dom-helpers.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAY;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AA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+ import { Fragment } from './types/index.js';
3
+ /**
4
+ * Create a VNode
5
+ *
6
+ * Runtime hyperscript function creates a plain VNode structure.
7
+ * The __type__ field should be added by babel-plugin at compile time.
8
+ * If not present, we detect it at runtime (slower but works).
9
+ *
10
+ * @param type - Element tag name or component function
11
+ * @param props - Properties (including on: prefixed events)
12
+ * @param children - Child nodes
13
+ * @returns VNode (plain structure, __type__ expected from babel-plugin)
14
+ */
15
+ export declare function hyperscript(type: string | Function | typeof Fragment, props: Record<string, any> | null, children: VNodeChild[]): VNode;
16
+ /**
17
+ * Alias for hyperscript (shorter name)
18
+ */
19
+ export declare const h: typeof hyperscript;
20
+ /**
21
+ * JSX automatic runtime exports
22
+ * These are standard exports for JSX automatic runtime
23
+ * All point to hyperscript since our babel plugin directly generates hyperscript calls
24
+ */
25
+ export declare const jsx: typeof hyperscript;
26
+ export declare const jsxs: typeof hyperscript;
27
+ export declare const jsxDEV: typeof hyperscript;
28
+ //# sourceMappingURL=vnode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vnode.d.ts","sourceRoot":"","sources":["../src/vnode.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AA+BvD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,QAAQ,EACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EACjC,QAAQ,EAAE,UAAU,EAAE,GACrB,KAAK,CAaP;AAED;;GAEG;AACH,eAAO,MAAM,CAAC,oBAAc,CAAC;AAE7B;;;;GAIG;AACH,eAAO,MAAM,GAAG,oBAAc,CAAC;AAC/B,eAAO,MAAM,IAAI,oBAAc,CAAC;AAChC,eAAO,MAAM,MAAM,oBAAc,CAAC"}
package/dist/vnode.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @fukict/runtime - VNode Creation (hyperscript)
3
+ *
4
+ * Create VNode from function calls
5
+ */
6
+ import { Fukict } from './component-class/fukict.js';
7
+ import { Fragment, VNodeType } from './types/index.js';
8
+ /**
9
+ * Detect VNode type at runtime (fallback if babel-plugin is not used)
10
+ */
11
+ function detectVNodeType(type) {
12
+ // Fragment
13
+ if (type === Fragment) {
14
+ return VNodeType.Fragment;
15
+ }
16
+ // Element (string tag name)
17
+ if (typeof type === 'string') {
18
+ return VNodeType.Element;
19
+ }
20
+ // Function
21
+ if (typeof type === 'function') {
22
+ // Class Component (extends Fukict)
23
+ if (type.prototype && type.prototype instanceof Fukict) {
24
+ return VNodeType.ClassComponent;
25
+ }
26
+ // Function Component
27
+ return VNodeType.FunctionComponent;
28
+ }
29
+ // Fallback to element
30
+ return VNodeType.Element;
31
+ }
32
+ /**
33
+ * Create a VNode
34
+ *
35
+ * Runtime hyperscript function creates a plain VNode structure.
36
+ * The __type__ field should be added by babel-plugin at compile time.
37
+ * If not present, we detect it at runtime (slower but works).
38
+ *
39
+ * @param type - Element tag name or component function
40
+ * @param props - Properties (including on: prefixed events)
41
+ * @param children - Child nodes
42
+ * @returns VNode (plain structure, __type__ expected from babel-plugin)
43
+ */
44
+ export function hyperscript(type, props, children) {
45
+ const vnode = {
46
+ type,
47
+ props: props || {},
48
+ children,
49
+ };
50
+ // If __type__ not set by babel-plugin, detect it at runtime
51
+ if (!('__type__' in vnode)) {
52
+ vnode.__type__ = detectVNodeType(type);
53
+ }
54
+ return vnode;
55
+ }
56
+ /**
57
+ * Alias for hyperscript (shorter name)
58
+ */
59
+ export const h = hyperscript;
60
+ /**
61
+ * JSX automatic runtime exports
62
+ * These are standard exports for JSX automatic runtime
63
+ * All point to hyperscript since our babel plugin directly generates hyperscript calls
64
+ */
65
+ export const jsx = hyperscript;
66
+ export const jsxs = hyperscript;
67
+ export const jsxDEV = hyperscript;
68
+ //# sourceMappingURL=v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AC;AAE7B;;;;GAIG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,WAAW,CAAC;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAC;AAChC,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@fukict/basic",
3
+ "version": "0.1.0",
4
+ "description": "Lightweight DOM rendering basic with extension mechanism",
5
+ "keywords": [
6
+ "fukict",
7
+ "basic",
8
+ "vdom",
9
+ "rendering",
10
+ "dom",
11
+ "browser"
12
+ ],
13
+ "bugs": {
14
+ "url": "https://github.com/fukict/fukict/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/fukict/fukict.git",
19
+ "directory": "packages/basic"
20
+ },
21
+ "license": "MIT",
22
+ "author": "Fukict Team",
23
+ "sideEffects": false,
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "browser": "./dist/index.js",
29
+ "default": "./dist/index.js"
30
+ },
31
+ "./jsx-runtime": {
32
+ "types": "./dist/jsx-runtime.d.ts",
33
+ "browser": "./dist/jsx-runtime.js",
34
+ "default": "./dist/jsx-runtime.js"
35
+ },
36
+ "./jsx-dev-runtime": {
37
+ "types": "./dist/jsx-runtime.d.ts",
38
+ "browser": "./dist/jsx-runtime.js",
39
+ "default": "./dist/jsx-runtime.js"
40
+ }
41
+ },
42
+ "main": "./dist/index.js",
43
+ "module": "./dist/index.js",
44
+ "types": "./dist/index.d.ts",
45
+ "files": [
46
+ "dist",
47
+ "README.md"
48
+ ],
49
+ "devDependencies": {
50
+ "typescript": "^5.6.3"
51
+ },
52
+ "engines": {
53
+ "node": ">=16.0.0"
54
+ },
55
+ "scripts": {
56
+ "build": "tsx ../../scripts/build-package.ts --pkg-name basic --no-watch",
57
+ "dev": "tsx ../../scripts/build-package.ts --pkg-name basic --watch",
58
+ "lint": "tsc --noEmit",
59
+ "typecheck": "tsc --noEmit"
60
+ }
61
+ }