@crossbind/port-expat-standalone-napi 2.0.0-beta.72 → 2.0.0-beta.75

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 CHANGED
@@ -1,4 +1,4 @@
1
- @crossbind/port-expat-standalone-napi ships the JavaScript bindings, types and data of the components below; the addons that link them are in its platform packages.
1
+ @crossbind/port-expat-standalone-napi ships the JavaScript bindings, types and data of the components below. Each of its platform packages carries the LICENSE of the addon it holds.
2
2
  The full license text of every component follows.
3
3
 
4
4
  Effective license expression (also package.json "license"):
@@ -14,7 +14,7 @@ advice; the compliance assessment is yours.
14
14
 
15
15
  ## crossbind — MIT
16
16
 
17
- - package: crossbind@2.0.0-beta.72
17
+ - package: crossbind@2.0.0-beta.75
18
18
  - source: https://github.com/crossbind/crossbind
19
19
  - note: the embind-jsi and embind-napi runtime and the bindings crossbind generates
20
20
 
@@ -44,7 +44,7 @@ SOFTWARE.
44
44
 
45
45
  ## emscripten-embind — MIT OR NCSA
46
46
 
47
- - package: @crossbind/core-embind-jsi@2.0.0-beta.72
47
+ - package: @crossbind/core-embind-jsi@2.0.0-beta.75
48
48
  - source: https://github.com/emscripten-core/emscripten
49
49
  - no license election recorded; the declared expression applies and all texts are included
50
50
  - note: Emscripten's embind, adapted by @crossbind/core-embind-jsi
@@ -148,35 +148,3 @@ ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
148
148
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
149
149
  SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
150
150
  ```
151
-
152
- ## expat — MIT
153
-
154
- - package: @crossbind/port-expat-darwin@2.0.0-beta.72
155
- - native version: 2.10.0
156
- - source: https://github.com/libexpat/libexpat/releases/download/R_2_10_0/expat-2.10.0.tar.gz (sha256: 5466a341f9c692ef7a958a6881311be597f8e1ce345984cf78414f54793dea4c)
157
-
158
- ```
159
- === LICENSE ===
160
-
161
- Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
162
- Copyright (c) 2001-2022 Expat maintainers
163
-
164
- Permission is hereby granted, free of charge, to any person obtaining
165
- a copy of this software and associated documentation files (the
166
- "Software"), to deal in the Software without restriction, including
167
- without limitation the rights to use, copy, modify, merge, publish,
168
- distribute, sublicense, and/or sell copies of the Software, and to
169
- permit persons to whom the Software is furnished to do so, subject to
170
- the following conditions:
171
-
172
- The above copyright notice and this permission notice shall be included
173
- in all copies or substantial portions of the Software.
174
-
175
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
176
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
177
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
178
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
179
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
180
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
181
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
182
- ```
@@ -2101,6 +2101,33 @@ function ownHandle(handle) {
2101
2101
  }
2102
2102
  return handle;
2103
2103
  }
2104
+ // A pointer a member function or property hands out can point into the object it was called on, or name that
2105
+ // object: its handle holds a clone of the object's handle, on the count the pointer's clones share, so the object goes
2106
+ // with the last of them, as the wasm glue does after utils/embindPointerOwners.js. Only a raw pointer, a NativePointer
2107
+ // and an emscripten::val can borrow: a copy and a smart pointer hold what they point at.
2108
+ function mayBorrow(type) {
2109
+ if (!type) return false;
2110
+ if (type.name === 'emscripten::val') return true;
2111
+ var cls = type.registeredClass;
2112
+ return !!cls && !type.isReference && (!type.isSmartPointer || cls.name === 'NativePointer');
2113
+ }
2114
+ function keepOwner(value, owner) {
2115
+ var $$ = value && value.$$;
2116
+ var held = owner && owner.$$;
2117
+ if (!$$ || !$$.count || $$.count.owner || !held || !held.ptr || held.preservePointerOnDelete || $$.count === held.count) {
2118
+ return value;
2119
+ }
2120
+ if ($$.smartPtr ? $$.ptrType.registeredClass.name === 'NativePointer' : !$$.count.owned) $$.count.owner = owner.clone();
2121
+ return value;
2122
+ }
2123
+ function keepsOwner(fn, type) {
2124
+ if (!mayBorrow(type)) return fn;
2125
+ var kept = function () {
2126
+ return keepOwner(fn.apply(this, arguments), this);
2127
+ };
2128
+ Object.defineProperty(kept, 'name', { value: fn.name });
2129
+ return kept;
2130
+ }
2104
2131
  function ClassHandle_clone() {
2105
2132
  if (!this.$$.ptr) {
2106
2133
  throwInstanceAlreadyDeleted(this);
@@ -2660,7 +2687,7 @@ function __embind_register_class_function(rawClassType,
2660
2687
 
2661
2688
  whenDependentTypesAreResolved([], rawArgTypes, function (argTypes) {
2662
2689
  //console.log(methodName);
2663
- var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync);
2690
+ var memberFunction = keepsOwner(craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync), argTypes[0]);
2664
2691
 
2665
2692
  // Replace the initial unbound-handler-stub function with the appropriate member function, now that all types
2666
2693
  // are resolved. If multiple overloads are registered for this function, the function goes into an overload table.
@@ -2746,7 +2773,7 @@ function __embind_register_class_property(classType,
2746
2773
  get: function () {
2747
2774
  // console.log('get -> ', this.$$.ptr);
2748
2775
  var ptr = validateThis(this, classType, humanName + ' getter');
2749
- return getterReturnType['fromWireType'](getter(getterContext, ptr));
2776
+ return keepOwner(getterReturnType['fromWireType'](getter(getterContext, ptr)), this);
2750
2777
  },
2751
2778
  enumerable: true
2752
2779
  };
@@ -1,5 +1,12 @@
1
- // Generated by crossbind - do not edit. Values are usable after init().
1
+ // Generated by crossbind - do not edit. Values are usable after initNative() resolves.
2
2
 
3
+ /** An embind std::vector proxy. Convert with Module.toArray / Module.toVector. */
4
+ export interface CppVector<T> {
5
+ size(): number;
6
+ get(index: number): T;
7
+ push_back(value: T): void;
8
+ delete(): void;
9
+ }
3
10
  export declare class XML_cp {
4
11
  constructor();
5
12
  numchildren: number;
@@ -150,4 +157,16 @@ export declare const XML_GetErrorLineNumber: any;
150
157
  export declare const XML_GetErrorColumnNumber: any;
151
158
  export declare const XML_GetErrorByteIndex: any;
152
159
  export declare let AllSymbols: Record<string, unknown>;
153
- export declare function initNative(config?: Record<string, unknown>): Promise<unknown>;
160
+ /** What initNative resolves to: the bound classes, toVector and toArray, and the members of the runtime it runs on. */
161
+ export interface NativeModule {
162
+ [name: string]: unknown;
163
+ XML_cp: typeof XML_cp;
164
+ XML_Memory_Handling_Suite: typeof XML_Memory_Handling_Suite;
165
+ XML_Encoding: typeof XML_Encoding;
166
+ XML_ParsingStatus: typeof XML_ParsingStatus;
167
+ XML_Expat_Version: typeof XML_Expat_Version;
168
+ XML_Feature: typeof XML_Feature;
169
+ toVector<T>(classOrName: unknown, array?: T[]): CppVector<T>;
170
+ toArray<T>(vector: CppVector<T> | T[]): T[];
171
+ }
172
+ export declare function initNative(config?: Record<string, unknown>): Promise<NativeModule>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossbind/port-expat-standalone-napi",
3
- "version": "2.0.0-beta.72",
3
+ "version": "2.0.0-beta.75",
4
4
  "nativeVersion": "2.10.0",
5
5
  "homepage": "https://crossbind.dev/ports/expat/",
6
6
  "repository": {
@@ -27,21 +27,21 @@
27
27
  "sbom.cdx.json"
28
28
  ],
29
29
  "optionalDependencies": {
30
- "@crossbind/port-expat-standalone-napi-darwin-arm64": "2.0.0-beta.72",
31
- "@crossbind/port-expat-standalone-napi-darwin-x64": "2.0.0-beta.72",
32
- "@crossbind/port-expat-standalone-napi-linux-arm64": "2.0.0-beta.72",
33
- "@crossbind/port-expat-standalone-napi-linux-x64": "2.0.0-beta.72",
34
- "@crossbind/port-expat-standalone-napi-linuxmusl-arm64": "2.0.0-beta.72",
35
- "@crossbind/port-expat-standalone-napi-linuxmusl-x64": "2.0.0-beta.72",
36
- "@crossbind/port-expat-standalone-napi-win32-arm64": "2.0.0-beta.72",
37
- "@crossbind/port-expat-standalone-napi-win32-x64": "2.0.0-beta.72"
30
+ "@crossbind/port-expat-standalone-napi-darwin-arm64": "2.0.0-beta.75",
31
+ "@crossbind/port-expat-standalone-napi-darwin-x64": "2.0.0-beta.75",
32
+ "@crossbind/port-expat-standalone-napi-linux-arm64": "2.0.0-beta.75",
33
+ "@crossbind/port-expat-standalone-napi-linux-x64": "2.0.0-beta.75",
34
+ "@crossbind/port-expat-standalone-napi-linuxmusl-arm64": "2.0.0-beta.75",
35
+ "@crossbind/port-expat-standalone-napi-linuxmusl-x64": "2.0.0-beta.75",
36
+ "@crossbind/port-expat-standalone-napi-win32-arm64": "2.0.0-beta.75",
37
+ "@crossbind/port-expat-standalone-napi-win32-x64": "2.0.0-beta.75"
38
38
  },
39
39
  "devDependencies": {
40
- "crossbind": "^2.0.0-beta.72",
41
- "@crossbind/port-expat-darwin": "^2.0.0-beta.72",
42
- "@crossbind/port-expat-linux": "^2.0.0-beta.72",
43
- "@crossbind/port-expat-linuxmusl": "^2.0.0-beta.72",
44
- "@crossbind/port-expat-win32": "^2.0.0-beta.72"
40
+ "crossbind": "^2.0.0-beta.75",
41
+ "@crossbind/port-expat-darwin": "^2.0.0-beta.75",
42
+ "@crossbind/port-expat-linux": "^2.0.0-beta.75",
43
+ "@crossbind/port-expat-linuxmusl": "^2.0.0-beta.75",
44
+ "@crossbind/port-expat-win32": "^2.0.0-beta.75"
45
45
  },
46
46
  "keywords": [
47
47
  "expat",
package/sbom.cdx.json CHANGED
@@ -6,13 +6,15 @@
6
6
  "component": {
7
7
  "type": "library",
8
8
  "name": "@crossbind/port-expat-standalone-napi",
9
- "version": "2.0.0-beta.72"
9
+ "version": "2.0.0-beta.75"
10
10
  }
11
11
  },
12
12
  "components": [
13
13
  {
14
14
  "type": "library",
15
15
  "name": "crossbind",
16
+ "version": "2.0.0-beta.75",
17
+ "purl": "pkg:generic/crossbind@2.0.0-beta.75",
16
18
  "licenses": [
17
19
  {
18
20
  "expression": "MIT"
@@ -28,6 +30,8 @@
28
30
  {
29
31
  "type": "library",
30
32
  "name": "emscripten-embind",
33
+ "version": "2.0.0-beta.75",
34
+ "purl": "pkg:generic/emscripten-embind@2.0.0-beta.75",
31
35
  "licenses": [
32
36
  {
33
37
  "expression": "MIT OR NCSA"
@@ -39,29 +43,6 @@
39
43
  "url": "https://github.com/emscripten-core/emscripten"
40
44
  }
41
45
  ]
42
- },
43
- {
44
- "type": "library",
45
- "name": "expat",
46
- "version": "2.10.0",
47
- "purl": "pkg:generic/expat@2.10.0",
48
- "licenses": [
49
- {
50
- "expression": "MIT"
51
- }
52
- ],
53
- "hashes": [
54
- {
55
- "alg": "SHA-256",
56
- "content": "5466a341f9c692ef7a958a6881311be597f8e1ce345984cf78414f54793dea4c"
57
- }
58
- ],
59
- "externalReferences": [
60
- {
61
- "type": "distribution",
62
- "url": "https://github.com/libexpat/libexpat/releases/download/R_2_10_0/expat-2.10.0.tar.gz"
63
- }
64
- ]
65
46
  }
66
47
  ]
67
48
  }