@nstudio/nativescript-compiler-effect-ui 9.2.0-alpha.13 → 9.2.0-alpha.22
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/LICENSE +7 -5
- package/dist/transform.js +51 -7
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nStudio
|
|
2
4
|
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -7,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
7
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
8
10
|
furnished to do so, subject to the following conditions:
|
|
9
11
|
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
|
11
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
12
14
|
|
|
13
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/transform.js
CHANGED
|
@@ -39,14 +39,26 @@ export function transformEffectSource(code, fileName) {
|
|
|
39
39
|
// Windows-only dead code inside shared masonkit common.ts (`_windowsCreateAnonymousText`, `windowsBreakRun`)
|
|
40
40
|
out = out.replace(/\bnew NativeScript\.Mason\.\w+\([^)]*\)/g, '(undefined as any)').replace(/\bNativeScript\.Mason\.\w+/g, 'any');
|
|
41
41
|
}
|
|
42
|
-
if (
|
|
43
|
-
// `objc!Mason.d.ts` omits `setMeasureForViewBlock`
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
if (/\/nativescript-masonkit\/common\.(?:ts|js)$/.test(norm)) {
|
|
43
|
+
// `objc!Mason.d.ts` omits `setMeasureForViewBlock`, `mason_addEventListener`, and `mason_removeEventListenerId`
|
|
44
|
+
// even though `Mason-Swift.h` exports them with ObjC block parameters; typing the receivers lets Swift emit
|
|
45
|
+
// direct typed ObjC-block calls instead of dynamic `objc_msgSend` (which skips `@?` block arguments).
|
|
46
|
+
const decls = [];
|
|
47
|
+
if (out.includes('setMeasureForViewBlock')) {
|
|
48
|
+
decls.push('interface NSCMason { setMeasureForViewBlock(view: any, block: (knownW: number, knownH: number, availW: number, availH: number) => any): void; }');
|
|
49
|
+
out = out.replace(/const mason = native\?\.mason \?\? native\?\.node\?\.mason;\s*if \(typeof mason\?\.setMeasureForViewBlock !== 'function'\) return;/, 'const mason = (native?.mason ?? native?.node?.mason) as NSCMason | undefined;\n if (!mason) return;');
|
|
50
|
+
}
|
|
51
|
+
if (out.includes('mason_addEventListener')) {
|
|
52
|
+
decls.push('interface NSObject { mason_addEventListener(event: string, listener: (event: any) => void): any; mason_removeEventListenerId(event: string, id: any): boolean; }');
|
|
53
|
+
out = out
|
|
54
|
+
.replace(/this\._view\.mason_addEventListener\(/g, '(this._view as NSObject).mason_addEventListener(')
|
|
55
|
+
.replace(/this\._view\.mason_removeEventListenerId\(/g, '(this._view as NSObject).mason_removeEventListenerId(');
|
|
56
|
+
}
|
|
57
|
+
if (decls.length) {
|
|
58
|
+
out = `declare global { ${decls.join(' ')} }\n` + out;
|
|
59
|
+
}
|
|
48
60
|
}
|
|
49
|
-
if (
|
|
61
|
+
if (/\/nativescript-masonkit\/style\.(?:ts|js)$/.test(norm)) {
|
|
50
62
|
out = out
|
|
51
63
|
.replace(/private view_: View;/, 'private view_: any;')
|
|
52
64
|
.replace(/static fromView\(view: View, nativeView\)/, 'static fromView(view: any, nativeView)')
|
|
@@ -67,6 +79,38 @@ export function transformEffectSource(code, fileName) {
|
|
|
67
79
|
if (norm.endsWith('/native/Native.ts')) {
|
|
68
80
|
out = out.replace(/Record<string,\s*NativeElement<any,\s*any,\s*any,\s*any,\s*any>>/g, 'Record<string, any>');
|
|
69
81
|
}
|
|
82
|
+
if (norm.endsWith('/platform/intl.ts')) {
|
|
83
|
+
// V8-without-ICU polyfill (`Date.prototype` / `Number.prototype` monkey-patching) is unnecessary under native Swift/Kotlin compilation.
|
|
84
|
+
return `export interface IntlBackend {}\nexport interface IntlPolyfillTarget {}\nexport interface IntlPolyfillReport { readonly dateTimeFormat: boolean; readonly numberFormat: boolean; readonly dateToLocale: boolean; readonly numberToLocale: boolean; }\nexport function createIntlPolyfill(_backend: IntlBackend): any { return {}; }\nexport function installIntlPolyfillWith(_backend: IntlBackend, _options?: any): IntlPolyfillReport { return { dateTimeFormat: false, numberFormat: false, dateToLocale: false, numberToLocale: false }; }\nexport function installIntlPolyfill(): void {}\n`;
|
|
85
|
+
}
|
|
86
|
+
if (norm.endsWith('/platform/intl-mapping.ts')) {
|
|
87
|
+
out = out.replace(/\bObject\(options\)/g, '(typeof options === "object" && options !== null ? options : {})');
|
|
88
|
+
}
|
|
89
|
+
if (norm.endsWith('/mason/svg.ts')) {
|
|
90
|
+
const cut = out.indexOf('\nconst isApple = (): boolean =>');
|
|
91
|
+
if (cut >= 0) {
|
|
92
|
+
out =
|
|
93
|
+
out.slice(0, cut) +
|
|
94
|
+
`\n@CSSType('svg')\nclass MasonSvgElement extends Div {\n _svgTree: SvgNode | undefined;\n setSvgTree(root: SvgNode): void {\n this._svgTree = root;\n }\n}\nexport function createSvgElementClass(): ElementConstructor {\n return MasonSvgElement as unknown as ElementConstructor;\n}\n`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (norm.endsWith('/mason/video.ts')) {
|
|
98
|
+
const cut = out.indexOf('\nconst isApple = (): boolean =>');
|
|
99
|
+
if (cut >= 0) {
|
|
100
|
+
out =
|
|
101
|
+
out.slice(0, cut) +
|
|
102
|
+
`\n@CSSType('video')\nclass MasonVideoElement extends Div {\n setSources(_sources: ReadonlyArray<VideoSource>): void {}\n play(): void {}\n pause(): void {}\n}\nexport function createVideoElementClass(): ElementConstructor {\n return MasonVideoElement as unknown as ElementConstructor;\n}\n`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (norm.endsWith('/mason/elements.ts')) {
|
|
106
|
+
out = out
|
|
107
|
+
.replace(/class MasonAnchor extends \(A as unknown as new \(\) => NSView & \{ followHref: \(\) => void \}\) \{/, 'class MasonAnchor extends A {')
|
|
108
|
+
.replace(/CSSType\('a'\)\(MasonAnchor\);/, '')
|
|
109
|
+
.replace(/function makeBlockElement\(tag: string\): ElementConstructor \{\s*class MasonBlockElement extends Div \{\}\s*CSSType\(tag\)\(MasonBlockElement\);\s*return MasonBlockElement as unknown as ElementConstructor;\s*\}/, `function makeBlockElement(_tag: string): ElementConstructor {\n return Div as unknown as ElementConstructor;\n}`);
|
|
110
|
+
}
|
|
111
|
+
if (norm.endsWith('/mason/input-native.ts')) {
|
|
112
|
+
return `import type { View as NSView } from '@nativescript/core';\nexport interface NativeInputHooks { readonly onEdit: () => void; readonly onReturn: () => void; }\nexport function syncNativeInput(_view: NSView, _tag: string): void {}\nexport function setNativeInputHooks(_view: NSView, _tag: string, _hooks: NativeInputHooks): void {}\nexport function dismissKeyboard(): void {}\nexport function installTapToDismissKeyboard(_view: NSView): () => void { return () => {}; }\n`;
|
|
113
|
+
}
|
|
70
114
|
}
|
|
71
115
|
if (/\bclass\b/.test(out)) {
|
|
72
116
|
out = transformEffectClasses(out, fileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nstudio/nativescript-compiler-effect-ui",
|
|
3
|
-
"version": "9.2.0-alpha.
|
|
3
|
+
"version": "9.2.0-alpha.22",
|
|
4
4
|
"description": "The Effect UI adapter of @nstudio/nativescript-compiler: compiles a NativeScript app written with @effect/ui and Effect v4 into a native iOS or Android app with no JavaScript runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"directory": "packages/effect-ui"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@nstudio/nativescript-compiler": "9.2.0-alpha.
|
|
27
|
+
"@nstudio/nativescript-compiler": "9.2.0-alpha.22"
|
|
28
28
|
},
|
|
29
29
|
"nativescript": {
|
|
30
30
|
"compilerAdapter": {
|