File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed
PlayBridgeJS/Sources/JavaScript
Sources/JavaScriptKit/Documentation.docc/Articles Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { init } from "./.build/plugins/PackageToJS/outputs/Package/index.js";
2
2
const { exports } = await init ( { } ) ;
3
3
4
4
const Greeter = exports . Greeter ;
5
- const greeter = new Greeter ( "World" ) ;
5
+ const greeter = Greeter . init ( "World" ) ;
6
6
const circle = exports . renderCircleSVG ( 100 ) ;
7
7
8
8
// Display the results
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export class BridgeJSPlayground {
52
52
createTS2Skeleton : this . createTS2Skeleton
53
53
}
54
54
} ) ;
55
- this . playBridgeJS = new exports . PlayBridgeJS ( ) ;
55
+ this . playBridgeJS = exports . PlayBridgeJS . init ( ) ;
56
56
console . log ( 'BridgeJS initialized successfully' ) ;
57
57
} catch ( error ) {
58
58
console . error ( 'Failed to initialize BridgeJS:' , error ) ;
@@ -162,4 +162,4 @@ export class BridgeJSPlayground {
162
162
hideError ( ) {
163
163
this . errorDisplay . classList . remove ( 'show' ) ;
164
164
}
165
- }
165
+ }
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ In JavaScript:
133
133
import { init } from " ./.build/plugins/PackageToJS/outputs/Package/index.js" ;
134
134
const { exports } = await init ({});
135
135
136
- const cart = new exports .ShoppingCart ();
136
+ const cart = exports .ShoppingCart . init ();
137
137
cart .addItem (" Laptop" , 999.99 , 1 );
138
138
cart .addItem (" Mouse" , 24.99 , 2 );
139
139
console .log (` Items in cart: ${cart .getItemCount ()} ` );
@@ -158,7 +158,7 @@ export interface ShoppingCart extends SwiftHeapObject {
158
158
159
159
export type Exports = {
160
160
ShoppingCart: {
161
- new (): ShoppingCart ;
161
+ init (): ShoppingCart ;
162
162
}
163
163
}
164
164
` ` `
@@ -175,8 +175,8 @@ You can export functions to specific namespaces by providing a namespace paramet
175
175
import JavaScriptKit
176
176
177
177
// Export a function to a custom namespace
178
- @JS (namespace : " MyModule.Utils" ) func namespacedFunction () -> String {
179
- return "namespaced"
178
+ @JS (namespace : " MyModule.Utils" ) func namespacedFunction () -> String {
179
+ return "namespaced"
180
180
}
181
181
` ` `
182
182
You can’t perform that action at this time.
0 commit comments