nitrogen 0.31.3 → 0.31.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitrogen",
3
- "version": "0.31.3",
3
+ "version": "0.31.4",
4
4
  "description": "The code-generator for react-native-nitro-modules.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "chalk": "^5.3.0",
39
- "react-native-nitro-modules": "^0.31.3",
39
+ "react-native-nitro-modules": "^0.31.4",
40
40
  "ts-morph": "^27.0.0",
41
41
  "yargs": "^18.0.0",
42
42
  "zod": "^4.0.5"
@@ -1,11 +0,0 @@
1
- import type { Language } from '../getPlatformSpecs.js';
2
- import type { HybridObjectSpec } from './HybridObjectSpec.js';
3
- /**
4
- * Returns true when the given {@linkcode memberName} is overriding a
5
- * property or method from any base class inside the given
6
- * {@linkcode hybridObject}'s prototype chain (all the way up).
7
- *
8
- * For example, `"toString"` would return `true` since it overrides from base HybridObject.
9
- * On Kotlin, `"hashCode"` would return `true` since it overrides from base `kotlin.Any`.
10
- */
11
- export declare function isMemberOverridingFromBase(memberName: string, hybridObject: HybridObjectSpec, language: Language): boolean;
@@ -1,64 +0,0 @@
1
- function getMemberNamesOfBaseType(language) {
2
- switch (language) {
3
- case 'c++':
4
- // C++ classes don't have any base type.
5
- return [];
6
- case 'swift':
7
- // Swift classes conform to `AnyObject`, but that doesn't have any properties
8
- return [];
9
- case 'kotlin':
10
- // Kotlin/JVM classes always extends `Any`, which has 3 methods
11
- return ['toString', 'equals', 'hashCode'];
12
- }
13
- }
14
- function getMemberNamesOfHybridObject() {
15
- const allKeys = {
16
- __type: true,
17
- dispose: true,
18
- equals: true,
19
- name: true,
20
- toString: true,
21
- };
22
- return Object.keys(allKeys);
23
- }
24
- function flatBaseTypes(type) {
25
- return type.baseTypes.flatMap((b) => [b, ...flatBaseTypes(b)]);
26
- }
27
- /**
28
- * Returns true when the given {@linkcode memberName} is overriding a
29
- * property or method from any base class inside the given
30
- * {@linkcode hybridObject}'s prototype chain (all the way up).
31
- *
32
- * For example, `"toString"` would return `true` since it overrides from base HybridObject.
33
- * On Kotlin, `"hashCode"` would return `true` since it overrides from base `kotlin.Any`.
34
- */
35
- export function isMemberOverridingFromBase(memberName, hybridObject, language) {
36
- // 1. Check if the HybridObject inherits from other HybridObjects,
37
- // if yes, check if those have properties of that given name.
38
- const allBases = flatBaseTypes(hybridObject);
39
- const anyBaseOverrides = allBases.some((h) => {
40
- if (h.properties.some((p) => p.name === memberName)) {
41
- return true;
42
- }
43
- if (h.methods.some((m) => m.name === memberName)) {
44
- return true;
45
- }
46
- return false;
47
- });
48
- if (anyBaseOverrides) {
49
- // A HybridObject base type has the same property name - we need to override it.
50
- return true;
51
- }
52
- // 2. Check if the base `HybridObject` type contains a property of the given name
53
- const baseHybridObjectProps = getMemberNamesOfHybridObject();
54
- if (baseHybridObjectProps.includes(memberName)) {
55
- return true;
56
- }
57
- // 3. Check if the base type in our language contains a property of the given name
58
- const baseTypeProps = getMemberNamesOfBaseType(language);
59
- if (baseTypeProps.includes(memberName)) {
60
- return true;
61
- }
62
- // 4. Apparently no base type has a property of that name - we are safe!
63
- return false;
64
- }
@@ -1,7 +0,0 @@
1
- import type { Method } from '../Method.js';
2
- /**
3
- * Returns `true` if the given {@linkcode method} is a
4
- * method that exists in the base `Object` type in Java.
5
- * If this is true, it needs an `override` modifier.
6
- */
7
- export declare function isBaseObjectMethodName(method: Method): boolean;
@@ -1,9 +0,0 @@
1
- const kotlinAnyMethodNames = ['equals', 'hashCode', 'toString'];
2
- /**
3
- * Returns `true` if the given {@linkcode method} is a
4
- * method that exists in the base `Object` type in Java.
5
- * If this is true, it needs an `override` modifier.
6
- */
7
- export function isBaseObjectMethodName(method) {
8
- return kotlinAnyMethodNames.includes(method.name);
9
- }
@@ -1,7 +0,0 @@
1
- import type { Type } from '../types/Type.js';
2
- /**
3
- * Returns `true` if the given {@linkcode type} is a datatype that
4
- * can be copied without running a copy constructor or special logic
5
- * to copy the data over. In other words; it's _primitively copyable_.
6
- */
7
- export declare function isPrimitivelyCopyable(type: Type): boolean;
@@ -1,18 +0,0 @@
1
- /**
2
- * Returns `true` if the given {@linkcode type} is a datatype that
3
- * can be copied without running a copy constructor or special logic
4
- * to copy the data over. In other words; it's _primitively copyable_.
5
- */
6
- export function isPrimitivelyCopyable(type) {
7
- switch (type.kind) {
8
- case 'number':
9
- case 'boolean':
10
- case 'bigint':
11
- case 'enum':
12
- case 'null':
13
- case 'void':
14
- return true;
15
- default:
16
- return false;
17
- }
18
- }
@@ -1,11 +0,0 @@
1
- import type { Language } from '../../getPlatformSpecs.js';
2
- import type { SourceFile, SourceImport } from '../SourceFile.js';
3
- import type { Type, TypeKind } from './Type.js';
4
- export declare class HybridObjectBaseType implements Type {
5
- constructor();
6
- get canBePassedByReference(): boolean;
7
- get kind(): TypeKind;
8
- getCode(language: Language): string;
9
- getExtraFiles(): SourceFile[];
10
- getRequiredImports(language: Language): SourceImport[];
11
- }
@@ -1,47 +0,0 @@
1
- import { getForwardDeclaration } from '../c++/getForwardDeclaration.js';
2
- export class HybridObjectBaseType {
3
- constructor() { }
4
- get canBePassedByReference() {
5
- // It's a shared_ptr<..>, no copy.
6
- return true;
7
- }
8
- get kind() {
9
- return 'hybrid-object-base';
10
- }
11
- getCode(language) {
12
- switch (language) {
13
- case 'c++':
14
- return `std::shared_ptr<HybridObject>`;
15
- default:
16
- throw new Error(`The base type \`HybridObject\` cannot be used directly in ${language} yet. Use a specific derived class of \`HybridObject\` instead!`);
17
- }
18
- }
19
- getExtraFiles() {
20
- return [];
21
- }
22
- getRequiredImports(language) {
23
- const imports = [];
24
- switch (language) {
25
- case 'c++':
26
- imports.push({
27
- language: 'c++',
28
- name: 'memory',
29
- space: 'system',
30
- }, {
31
- name: `NitroModules/HybridObject.hpp`,
32
- forwardDeclaration: getForwardDeclaration('class', 'HybridObject', 'margelo::nitro'),
33
- language: 'c++',
34
- space: 'system',
35
- });
36
- break;
37
- case 'kotlin':
38
- imports.push({
39
- name: 'com.margelo.nitro.core.HybridObject',
40
- space: 'system',
41
- language: 'kotlin',
42
- });
43
- break;
44
- }
45
- return imports;
46
- }
47
- }