@hypen-space/core 0.2.12 → 0.3.1
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/README.md +182 -11
- package/dist/src/app.js +470 -44
- package/dist/src/app.js.map +7 -5
- package/dist/src/components/builtin.js +470 -44
- package/dist/src/components/builtin.js.map +7 -5
- package/dist/src/discovery.js +559 -65
- package/dist/src/discovery.js.map +8 -6
- package/dist/src/engine.js +18 -9
- package/dist/src/engine.js.map +3 -3
- package/dist/src/index.browser.js +870 -81
- package/dist/src/index.browser.js.map +11 -7
- package/dist/src/index.js +1591 -125
- package/dist/src/index.js.map +17 -10
- package/dist/src/plugin.js +2 -2
- package/dist/src/plugin.js.map +2 -2
- package/dist/src/remote/client.js +525 -35
- package/dist/src/remote/client.js.map +7 -4
- package/dist/src/remote/index.js +1796 -35
- package/dist/src/remote/index.js.map +13 -4
- package/dist/src/router.js +55 -29
- package/dist/src/router.js.map +3 -3
- package/dist/src/state.js +57 -29
- package/dist/src/state.js.map +3 -3
- package/package.json +8 -2
- package/src/app.ts +292 -13
- package/src/discovery.ts +123 -18
- package/src/disposable.ts +281 -0
- package/src/engine.ts +29 -10
- package/src/hypen.ts +209 -0
- package/src/index.browser.ts +17 -1
- package/src/index.ts +148 -12
- package/src/logger.ts +338 -0
- package/src/plugin.ts +1 -1
- package/src/remote/client.ts +263 -56
- package/src/remote/index.ts +25 -1
- package/src/remote/server.ts +652 -0
- package/src/remote/session.ts +256 -0
- package/src/remote/types.ts +68 -1
- package/src/result.ts +260 -0
- package/src/retry.ts +306 -0
- package/src/state.ts +103 -45
- package/wasm-browser/README.md +4 -0
- package/wasm-browser/hypen_engine_bg.wasm +0 -0
- package/wasm-browser/package.json +1 -1
- package/wasm-node/README.md +4 -0
- package/wasm-node/hypen_engine_bg.wasm +0 -0
- package/wasm-node/package.json +1 -1
- package/wasm-browser/hypen_engine_bg.js +0 -736
- package/wasm-node/hypen_engine_bg.js +0 -736
package/dist/src/plugin.js
CHANGED
|
@@ -103,7 +103,7 @@ export default { module: _module, template: ${JSON.stringify(template)}, name: $
|
|
|
103
103
|
} else {
|
|
104
104
|
log("No module found, creating stateless component");
|
|
105
105
|
contents = `
|
|
106
|
-
import { app } from "@hypen/core";
|
|
106
|
+
import { app } from "@hypen-space/core";
|
|
107
107
|
const _module = app.defineState({}).build();
|
|
108
108
|
export const module = _module;
|
|
109
109
|
export const template = ${JSON.stringify(template)};
|
|
@@ -131,4 +131,4 @@ export {
|
|
|
131
131
|
plugin_default as default
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
//# debugId=
|
|
134
|
+
//# debugId=F7A9B786256270A664756E2164756E21
|
package/dist/src/plugin.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/plugin.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Enhanced Bun Plugin for Hypen\n *\n * Automatically pairs .hypen templates with their TypeScript modules.\n *\n * Usage:\n * import Counter from \"./Counter.hypen\";\n * // Returns: { module, template, name: \"Counter\" }\n *\n * Supported conventions:\n * 1. Sibling: Name.ts + Name.hypen\n * 2. Folder: Name/component.ts + Name/component.hypen\n * 3. Index: Name/index.ts + Name/index.hypen\n */\n\nimport type { BunPlugin } from \"bun\";\nimport { readFileSync, existsSync } from \"fs\";\nimport { dirname, basename, join, resolve } from \"path\";\n\nexport interface HypenPluginOptions {\n /**\n * Enable debug logging\n */\n debug?: boolean;\n\n /**\n * Custom patterns for finding module files\n * Default: [\"sibling\", \"component\", \"index\"]\n */\n patterns?: (\"sibling\" | \"component\" | \"index\")[];\n}\n\n/**\n * Find the matching TypeScript module for a .hypen file\n */\nfunction findModulePath(\n hypenPath: string,\n patterns: (\"sibling\" | \"component\" | \"index\")[]\n): string | null {\n const dir = dirname(hypenPath);\n const baseName = basename(hypenPath, \".hypen\");\n const parentDir = dirname(dir);\n const folderName = basename(dir);\n\n for (const pattern of patterns) {\n let candidatePath: string | null = null;\n\n switch (pattern) {\n case \"sibling\":\n // Name.hypen -> Name.ts (same directory)\n candidatePath = join(dir, `${baseName}.ts`);\n break;\n\n case \"component\":\n // Name/component.hypen -> Name/component.ts\n if (baseName === \"component\") {\n candidatePath = join(dir, \"component.ts\");\n }\n break;\n\n case \"index\":\n // Name/index.hypen -> Name/index.ts\n if (baseName === \"index\") {\n candidatePath = join(dir, \"index.ts\");\n }\n break;\n }\n\n if (candidatePath && existsSync(candidatePath)) {\n return candidatePath;\n }\n }\n\n return null;\n}\n\n/**\n * Determine the component name from the file path\n */\nfunction getComponentName(hypenPath: string): string {\n const baseName = basename(hypenPath, \".hypen\");\n\n // If file is component.hypen or index.hypen, use parent folder name\n if (baseName === \"component\" || baseName === \"index\") {\n return basename(dirname(hypenPath));\n }\n\n // Otherwise use the file name\n return baseName;\n}\n\n/**\n * Parse import statements from Hypen DSL (for future use)\n */\nfunction parseImports(\n text: string\n): Array<{ names: string[]; source: string }> {\n const imports: Array<{ names: string[]; source: string }> = [];\n const importRegex =\n /import\\s+(?:\\{([^}]+)\\}|(\\w+))\\s+from\\s+[\"']([^\"']+)[\"']/g;\n\n let match;\n while ((match = importRegex.exec(text)) !== null) {\n const [, namedImports, defaultImport, source] = match;\n\n if (!source) continue;\n\n let names: string[];\n if (namedImports) {\n names = namedImports\n .split(\",\")\n .map((n) => n.trim())\n .filter((n) => n.length > 0);\n } else if (defaultImport) {\n names = [defaultImport];\n } else {\n continue;\n }\n\n imports.push({ names, source });\n }\n\n return imports;\n}\n\n/**\n * Remove import statements from Hypen template\n */\nfunction removeImports(text: string): string {\n return text.replace(\n /import\\s+(?:\\{[^}]+\\}|\\w+)\\s+from\\s+[\"'][^\"']+[\"']\\s*/g,\n \"\"\n );\n}\n\n/**\n * Create the enhanced Hypen plugin for Bun\n */\nexport function hypenPlugin(options: HypenPluginOptions = {}): BunPlugin {\n const { debug = false, patterns = [\"sibling\", \"component\", \"index\"] } =\n options;\n\n const log = debug\n ? (...args: unknown[]) => console.log(\"[hypen-plugin]\", ...args)\n : () => {};\n\n return {\n name: \"hypen-loader\",\n async setup(build) {\n build.onLoad({ filter: /\\.hypen$/ }, async (args) => {\n const hypenPath = resolve(args.path);\n log(\"Loading:\", hypenPath);\n\n // Read the template\n const templateRaw = readFileSync(hypenPath, \"utf-8\");\n\n // Parse and remove imports\n const imports = parseImports(templateRaw);\n const template = removeImports(templateRaw).trim();\n\n if (imports.length > 0) {\n log(\"Found imports:\", imports);\n }\n\n // Get component name\n const componentName = getComponentName(hypenPath);\n log(\"Component name:\", componentName);\n\n // Find matching module\n const modulePath = findModulePath(hypenPath, patterns);\n log(\"Module path:\", modulePath);\n\n let contents: string;\n\n if (modulePath) {\n // Has a TypeScript module - import it\n const relativeModulePath = modulePath.replace(/\\.ts$/, \".js\");\n contents = `\nimport _module from \"${relativeModulePath}\";\nexport const module = _module;\nexport const template = ${JSON.stringify(template)};\nexport const name = ${JSON.stringify(componentName)};\nexport default { module: _module, template: ${JSON.stringify(template)}, name: ${JSON.stringify(componentName)} };\n`;\n } else {\n // No TypeScript module - create stateless component\n log(\"No module found, creating stateless component\");\n contents = `\nimport { app } from \"@hypen/core\";\nconst _module = app.defineState({}).build();\nexport const module = _module;\nexport const template = ${JSON.stringify(template)};\nexport const name = ${JSON.stringify(componentName)};\nexport default { module: _module, template: ${JSON.stringify(template)}, name: ${JSON.stringify(componentName)} };\n`;\n }\n\n return {\n contents,\n loader: \"js\",\n };\n });\n },\n };\n}\n\n/**\n * Default plugin instance with standard options\n */\nexport const defaultHypenPlugin = hypenPlugin();\n\n/**\n * Register the plugin globally (call this in your preload file)\n */\nexport function registerHypenPlugin(options?: HypenPluginOptions): void {\n Bun.plugin(hypenPlugin(options));\n}\n\nexport default hypenPlugin;\n"
|
|
5
|
+
"/**\n * Enhanced Bun Plugin for Hypen\n *\n * Automatically pairs .hypen templates with their TypeScript modules.\n *\n * Usage:\n * import Counter from \"./Counter.hypen\";\n * // Returns: { module, template, name: \"Counter\" }\n *\n * Supported conventions:\n * 1. Sibling: Name.ts + Name.hypen\n * 2. Folder: Name/component.ts + Name/component.hypen\n * 3. Index: Name/index.ts + Name/index.hypen\n */\n\nimport type { BunPlugin } from \"bun\";\nimport { readFileSync, existsSync } from \"fs\";\nimport { dirname, basename, join, resolve } from \"path\";\n\nexport interface HypenPluginOptions {\n /**\n * Enable debug logging\n */\n debug?: boolean;\n\n /**\n * Custom patterns for finding module files\n * Default: [\"sibling\", \"component\", \"index\"]\n */\n patterns?: (\"sibling\" | \"component\" | \"index\")[];\n}\n\n/**\n * Find the matching TypeScript module for a .hypen file\n */\nfunction findModulePath(\n hypenPath: string,\n patterns: (\"sibling\" | \"component\" | \"index\")[]\n): string | null {\n const dir = dirname(hypenPath);\n const baseName = basename(hypenPath, \".hypen\");\n const parentDir = dirname(dir);\n const folderName = basename(dir);\n\n for (const pattern of patterns) {\n let candidatePath: string | null = null;\n\n switch (pattern) {\n case \"sibling\":\n // Name.hypen -> Name.ts (same directory)\n candidatePath = join(dir, `${baseName}.ts`);\n break;\n\n case \"component\":\n // Name/component.hypen -> Name/component.ts\n if (baseName === \"component\") {\n candidatePath = join(dir, \"component.ts\");\n }\n break;\n\n case \"index\":\n // Name/index.hypen -> Name/index.ts\n if (baseName === \"index\") {\n candidatePath = join(dir, \"index.ts\");\n }\n break;\n }\n\n if (candidatePath && existsSync(candidatePath)) {\n return candidatePath;\n }\n }\n\n return null;\n}\n\n/**\n * Determine the component name from the file path\n */\nfunction getComponentName(hypenPath: string): string {\n const baseName = basename(hypenPath, \".hypen\");\n\n // If file is component.hypen or index.hypen, use parent folder name\n if (baseName === \"component\" || baseName === \"index\") {\n return basename(dirname(hypenPath));\n }\n\n // Otherwise use the file name\n return baseName;\n}\n\n/**\n * Parse import statements from Hypen DSL (for future use)\n */\nfunction parseImports(\n text: string\n): Array<{ names: string[]; source: string }> {\n const imports: Array<{ names: string[]; source: string }> = [];\n const importRegex =\n /import\\s+(?:\\{([^}]+)\\}|(\\w+))\\s+from\\s+[\"']([^\"']+)[\"']/g;\n\n let match;\n while ((match = importRegex.exec(text)) !== null) {\n const [, namedImports, defaultImport, source] = match;\n\n if (!source) continue;\n\n let names: string[];\n if (namedImports) {\n names = namedImports\n .split(\",\")\n .map((n) => n.trim())\n .filter((n) => n.length > 0);\n } else if (defaultImport) {\n names = [defaultImport];\n } else {\n continue;\n }\n\n imports.push({ names, source });\n }\n\n return imports;\n}\n\n/**\n * Remove import statements from Hypen template\n */\nfunction removeImports(text: string): string {\n return text.replace(\n /import\\s+(?:\\{[^}]+\\}|\\w+)\\s+from\\s+[\"'][^\"']+[\"']\\s*/g,\n \"\"\n );\n}\n\n/**\n * Create the enhanced Hypen plugin for Bun\n */\nexport function hypenPlugin(options: HypenPluginOptions = {}): BunPlugin {\n const { debug = false, patterns = [\"sibling\", \"component\", \"index\"] } =\n options;\n\n const log = debug\n ? (...args: unknown[]) => console.log(\"[hypen-plugin]\", ...args)\n : () => {};\n\n return {\n name: \"hypen-loader\",\n async setup(build) {\n build.onLoad({ filter: /\\.hypen$/ }, async (args) => {\n const hypenPath = resolve(args.path);\n log(\"Loading:\", hypenPath);\n\n // Read the template\n const templateRaw = readFileSync(hypenPath, \"utf-8\");\n\n // Parse and remove imports\n const imports = parseImports(templateRaw);\n const template = removeImports(templateRaw).trim();\n\n if (imports.length > 0) {\n log(\"Found imports:\", imports);\n }\n\n // Get component name\n const componentName = getComponentName(hypenPath);\n log(\"Component name:\", componentName);\n\n // Find matching module\n const modulePath = findModulePath(hypenPath, patterns);\n log(\"Module path:\", modulePath);\n\n let contents: string;\n\n if (modulePath) {\n // Has a TypeScript module - import it\n const relativeModulePath = modulePath.replace(/\\.ts$/, \".js\");\n contents = `\nimport _module from \"${relativeModulePath}\";\nexport const module = _module;\nexport const template = ${JSON.stringify(template)};\nexport const name = ${JSON.stringify(componentName)};\nexport default { module: _module, template: ${JSON.stringify(template)}, name: ${JSON.stringify(componentName)} };\n`;\n } else {\n // No TypeScript module - create stateless component\n log(\"No module found, creating stateless component\");\n contents = `\nimport { app } from \"@hypen-space/core\";\nconst _module = app.defineState({}).build();\nexport const module = _module;\nexport const template = ${JSON.stringify(template)};\nexport const name = ${JSON.stringify(componentName)};\nexport default { module: _module, template: ${JSON.stringify(template)}, name: ${JSON.stringify(componentName)} };\n`;\n }\n\n return {\n contents,\n loader: \"js\",\n };\n });\n },\n };\n}\n\n/**\n * Default plugin instance with standard options\n */\nexport const defaultHypenPlugin = hypenPlugin();\n\n/**\n * Register the plugin globally (call this in your preload file)\n */\nexport function registerHypenPlugin(options?: HypenPluginOptions): void {\n Bun.plugin(hypenPlugin(options));\n}\n\nexport default hypenPlugin;\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;AAgBA;AACA;AAkBA,SAAS,cAAc,CACrB,WACA,UACe;AAAA,EACf,MAAM,MAAM,QAAQ,SAAS;AAAA,EAC7B,MAAM,WAAW,SAAS,WAAW,QAAQ;AAAA,EAC7C,MAAM,YAAY,QAAQ,GAAG;AAAA,EAC7B,MAAM,aAAa,SAAS,GAAG;AAAA,EAE/B,WAAW,WAAW,UAAU;AAAA,IAC9B,IAAI,gBAA+B;AAAA,IAEnC,QAAQ;AAAA,WACD;AAAA,QAEH,gBAAgB,KAAK,KAAK,GAAG,aAAa;AAAA,QAC1C;AAAA,WAEG;AAAA,QAEH,IAAI,aAAa,aAAa;AAAA,UAC5B,gBAAgB,KAAK,KAAK,cAAc;AAAA,QAC1C;AAAA,QACA;AAAA,WAEG;AAAA,QAEH,IAAI,aAAa,SAAS;AAAA,UACxB,gBAAgB,KAAK,KAAK,UAAU;AAAA,QACtC;AAAA,QACA;AAAA;AAAA,IAGJ,IAAI,iBAAiB,WAAW,aAAa,GAAG;AAAA,MAC9C,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO;AAAA;AAMT,SAAS,gBAAgB,CAAC,WAA2B;AAAA,EACnD,MAAM,WAAW,SAAS,WAAW,QAA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