@lokascript/hyperscript-adapter 2.9.2 → 2.9.4
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/hyperscript-i18n-ar.global.js +6 -5
- package/dist/hyperscript-i18n-bn.global.js +6 -5
- package/dist/hyperscript-i18n-de.global.js +6 -5
- package/dist/hyperscript-i18n-east-asian.global.js +6 -5
- package/dist/hyperscript-i18n-en.global.js +8 -7
- package/dist/hyperscript-i18n-es.global.js +6 -5
- package/dist/hyperscript-i18n-fr.global.js +6 -5
- package/dist/hyperscript-i18n-he.global.js +6 -5
- package/dist/hyperscript-i18n-hi.global.js +6 -5
- package/dist/hyperscript-i18n-id.global.js +6 -5
- package/dist/hyperscript-i18n-it.global.js +6 -5
- package/dist/hyperscript-i18n-ja.global.js +6 -5
- package/dist/hyperscript-i18n-ko.global.js +6 -5
- package/dist/hyperscript-i18n-lite.global.js +2 -1
- package/dist/hyperscript-i18n-ms.global.js +6 -5
- package/dist/hyperscript-i18n-pl.global.js +6 -5
- package/dist/hyperscript-i18n-pt.global.js +6 -5
- package/dist/hyperscript-i18n-qu.global.js +6 -5
- package/dist/hyperscript-i18n-ru.global.js +6 -5
- package/dist/hyperscript-i18n-slavic.global.js +6 -5
- package/dist/hyperscript-i18n-south-asian.global.js +6 -5
- package/dist/hyperscript-i18n-southeast-asian.global.js +6 -5
- package/dist/hyperscript-i18n-sw.global.js +6 -5
- package/dist/hyperscript-i18n-th.global.js +6 -5
- package/dist/hyperscript-i18n-tl.global.js +6 -5
- package/dist/hyperscript-i18n-tr.global.js +6 -5
- package/dist/hyperscript-i18n-uk.global.js +6 -5
- package/dist/hyperscript-i18n-vi.global.js +6 -5
- package/dist/hyperscript-i18n-western.global.js +6 -5
- package/dist/hyperscript-i18n-zh.global.js +6 -5
- package/dist/hyperscript-i18n.global.js +28 -28
- package/dist/hyperscript-i18n.global.js.map +1 -1
- package/dist/index.cjs +48 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +48 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/attribute-translator.ts +96 -0
- package/src/browser-lite.ts +3 -11
- package/src/browser.ts +5 -36
- package/src/bundles/shared.ts +4 -35
- package/src/generated/syntax-table.ts +2 -2
- package/src/plugin.ts +5 -25
- package/src/slim-plugin.ts +3 -11
|
@@ -45,7 +45,7 @@ export const SYNTAX: Record<string, readonly [string, string][]> = {
|
|
|
45
45
|
measure: [['patient', ''], ['source', 'of']],
|
|
46
46
|
morph: [['patient', ''], ['destination', 'to']],
|
|
47
47
|
on: [['event', ''], ['source', 'from']],
|
|
48
|
-
open: [['
|
|
48
|
+
open: [['patient', ''], ['style', 'as']],
|
|
49
49
|
pick: [['patient', ''], ['source', 'from']],
|
|
50
50
|
prepend: [['patient', ''], ['destination', 'to']],
|
|
51
51
|
process: [['patient', 'partials in']],
|
|
@@ -68,7 +68,7 @@ export const SYNTAX: Record<string, readonly [string, string][]> = {
|
|
|
68
68
|
take: [['patient', ''], ['source', 'from']],
|
|
69
69
|
tell: [['destination', '']],
|
|
70
70
|
throw: [['patient', '']],
|
|
71
|
-
toggle: [['patient', ''], ['destination', 'on']],
|
|
71
|
+
toggle: [['patient', ''], ['destination', 'on'], ['duration', 'for']],
|
|
72
72
|
transition: [['patient', ''], ['goal', 'to'], ['destination', 'on'], ['duration', 'over'], ['style', 'with']],
|
|
73
73
|
trigger: [['event', ''], ['destination', 'on']],
|
|
74
74
|
unless: [['condition', '']],
|
package/src/plugin.ts
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* _hyperscript Plugin
|
|
3
3
|
*
|
|
4
|
-
* Registers with _hyperscript.use() to
|
|
5
|
-
*
|
|
4
|
+
* Registers with _hyperscript.use() to rewrite non-English hyperscript
|
|
5
|
+
* attributes into English before _hyperscript.org parses them.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { resolveLanguage } from './language-resolver';
|
|
9
9
|
import { preprocessToEnglish, type PreprocessorConfig } from './preprocessor';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The _hyperscript global object shape (minimal subset we need).
|
|
13
|
-
*/
|
|
14
|
-
interface HyperscriptGlobal {
|
|
15
|
-
internals: {
|
|
16
|
-
runtime: HyperscriptRuntime;
|
|
17
|
-
};
|
|
18
|
-
config: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface HyperscriptRuntime {
|
|
22
|
-
getScript(elt: Element): string | null;
|
|
23
|
-
}
|
|
10
|
+
import { installAttributeTranslator, type HyperscriptHost } from './attribute-translator';
|
|
24
11
|
|
|
25
12
|
export interface PluginOptions extends Partial<PreprocessorConfig> {
|
|
26
13
|
/** Default language for all elements (overridable per-element). */
|
|
@@ -48,14 +35,7 @@ export interface PluginOptions extends Partial<PreprocessorConfig> {
|
|
|
48
35
|
*/
|
|
49
36
|
export function hyperscriptI18n(options: PluginOptions = {}) {
|
|
50
37
|
return function plugin(hs: unknown): void {
|
|
51
|
-
|
|
52
|
-
const runtime = internals.runtime;
|
|
53
|
-
const originalGetScript = runtime.getScript.bind(runtime);
|
|
54
|
-
|
|
55
|
-
runtime.getScript = function (elt: Element): string | null {
|
|
56
|
-
const src = originalGetScript(elt);
|
|
57
|
-
if (!src) return null;
|
|
58
|
-
|
|
38
|
+
installAttributeTranslator(hs as HyperscriptHost, (src, elt) => {
|
|
59
39
|
// Resolve language
|
|
60
40
|
const lang = resolveLanguageWithOptions(elt, options);
|
|
61
41
|
|
|
@@ -79,7 +59,7 @@ export function hyperscriptI18n(options: PluginOptions = {}) {
|
|
|
79
59
|
}
|
|
80
60
|
|
|
81
61
|
return english;
|
|
82
|
-
};
|
|
62
|
+
});
|
|
83
63
|
};
|
|
84
64
|
}
|
|
85
65
|
|
package/src/slim-plugin.ts
CHANGED
|
@@ -9,21 +9,13 @@ import { resolveLanguage } from './language-resolver';
|
|
|
9
9
|
import { preprocessToEnglish } from './slim-preprocessor';
|
|
10
10
|
import type { PreprocessorConfig } from './preprocessor';
|
|
11
11
|
import type { PluginOptions } from './plugin';
|
|
12
|
+
import { installAttributeTranslator, type HyperscriptHost } from './attribute-translator';
|
|
12
13
|
|
|
13
14
|
export type { PluginOptions };
|
|
14
15
|
|
|
15
16
|
export function hyperscriptI18n(options: PluginOptions = {}) {
|
|
16
17
|
return function plugin(hs: unknown): void {
|
|
17
|
-
|
|
18
|
-
internals: { runtime: { getScript: (elt: Element) => string | null } };
|
|
19
|
-
};
|
|
20
|
-
const runtime = internals.runtime;
|
|
21
|
-
const originalGetScript = runtime.getScript.bind(runtime);
|
|
22
|
-
|
|
23
|
-
runtime.getScript = function (elt: Element): string | null {
|
|
24
|
-
const src = originalGetScript(elt);
|
|
25
|
-
if (!src) return null;
|
|
26
|
-
|
|
18
|
+
installAttributeTranslator(hs as HyperscriptHost, (src, elt) => {
|
|
27
19
|
const lang = resolveLanguageWithOptions(elt, options);
|
|
28
20
|
if (!lang || lang === 'en') return src;
|
|
29
21
|
|
|
@@ -34,7 +26,7 @@ export function hyperscriptI18n(options: PluginOptions = {}) {
|
|
|
34
26
|
}
|
|
35
27
|
|
|
36
28
|
return english;
|
|
37
|
-
};
|
|
29
|
+
});
|
|
38
30
|
};
|
|
39
31
|
}
|
|
40
32
|
|