@ricsam/quickjs-core 0.0.1 → 0.2.1

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.
Files changed (79) hide show
  1. package/README.md +36 -43
  2. package/dist/cjs/blob.cjs +197 -0
  3. package/dist/cjs/blob.cjs.map +10 -0
  4. package/dist/cjs/class-builder.cjs +244 -0
  5. package/dist/cjs/class-builder.cjs.map +10 -0
  6. package/dist/cjs/dom-exception.cjs +95 -0
  7. package/dist/cjs/dom-exception.cjs.map +10 -0
  8. package/dist/cjs/file.cjs +234 -0
  9. package/dist/cjs/file.cjs.map +10 -0
  10. package/dist/cjs/function-builder.cjs +70 -0
  11. package/dist/cjs/function-builder.cjs.map +10 -0
  12. package/dist/cjs/index.cjs +143 -0
  13. package/dist/cjs/index.cjs.map +10 -0
  14. package/dist/cjs/marshal.cjs +191 -0
  15. package/dist/cjs/marshal.cjs.map +10 -0
  16. package/dist/cjs/package.json +5 -0
  17. package/dist/cjs/readable-stream.cjs +588 -0
  18. package/dist/cjs/readable-stream.cjs.map +10 -0
  19. package/dist/cjs/scope.cjs +76 -0
  20. package/dist/cjs/scope.cjs.map +10 -0
  21. package/dist/cjs/transform-stream.cjs +152 -0
  22. package/dist/cjs/transform-stream.cjs.map +10 -0
  23. package/dist/cjs/types.cjs +39 -0
  24. package/dist/cjs/types.cjs.map +10 -0
  25. package/dist/cjs/unmarshal.cjs +254 -0
  26. package/dist/cjs/unmarshal.cjs.map +10 -0
  27. package/dist/cjs/url-search-params.cjs +165 -0
  28. package/dist/cjs/url-search-params.cjs.map +10 -0
  29. package/dist/cjs/url.cjs +183 -0
  30. package/dist/cjs/url.cjs.map +10 -0
  31. package/dist/cjs/writable-stream.cjs +513 -0
  32. package/dist/cjs/writable-stream.cjs.map +10 -0
  33. package/dist/mjs/blob.mjs +166 -0
  34. package/dist/mjs/blob.mjs.map +10 -0
  35. package/dist/mjs/class-builder.mjs +213 -0
  36. package/dist/mjs/class-builder.mjs.map +10 -0
  37. package/dist/mjs/dom-exception.mjs +64 -0
  38. package/dist/mjs/dom-exception.mjs.map +10 -0
  39. package/dist/mjs/file.mjs +203 -0
  40. package/dist/mjs/file.mjs.map +10 -0
  41. package/dist/mjs/function-builder.mjs +39 -0
  42. package/dist/mjs/function-builder.mjs.map +10 -0
  43. package/dist/mjs/index.mjs +132 -0
  44. package/dist/mjs/index.mjs.map +10 -0
  45. package/dist/mjs/marshal.mjs +160 -0
  46. package/dist/mjs/marshal.mjs.map +10 -0
  47. package/dist/mjs/package.json +5 -0
  48. package/dist/mjs/readable-stream.mjs +557 -0
  49. package/dist/mjs/readable-stream.mjs.map +10 -0
  50. package/dist/mjs/scope.mjs +45 -0
  51. package/dist/mjs/scope.mjs.map +10 -0
  52. package/dist/mjs/transform-stream.mjs +121 -0
  53. package/dist/mjs/transform-stream.mjs.map +10 -0
  54. package/dist/mjs/types.mjs +8 -0
  55. package/dist/mjs/types.mjs.map +10 -0
  56. package/dist/mjs/unmarshal.mjs +223 -0
  57. package/dist/mjs/unmarshal.mjs.map +10 -0
  58. package/dist/mjs/url-search-params.mjs +134 -0
  59. package/dist/mjs/url-search-params.mjs.map +10 -0
  60. package/dist/mjs/url.mjs +152 -0
  61. package/dist/mjs/url.mjs.map +10 -0
  62. package/dist/mjs/writable-stream.mjs +482 -0
  63. package/dist/mjs/writable-stream.mjs.map +10 -0
  64. package/dist/types/blob.d.ts +19 -0
  65. package/dist/types/class-builder.d.ts +62 -0
  66. package/dist/types/dom-exception.d.ts +8 -0
  67. package/dist/types/file.d.ts +10 -0
  68. package/dist/types/function-builder.d.ts +23 -0
  69. package/dist/types/index.d.ts +45 -0
  70. package/dist/types/marshal.d.ts +30 -0
  71. package/dist/types/scope.d.ts +18 -0
  72. package/dist/types/streams/readable-stream.d.ts +18 -0
  73. package/dist/types/streams/transform-stream.d.ts +6 -0
  74. package/dist/types/streams/writable-stream.d.ts +14 -0
  75. package/dist/types/types.d.ts +83 -0
  76. package/dist/types/unmarshal.d.ts +14 -0
  77. package/dist/types/url-search-params.d.ts +12 -0
  78. package/dist/types/url.d.ts +30 -0
  79. package/package.json +50 -6
@@ -0,0 +1,76 @@
1
+ // @bun @bun-cjs
2
+ (function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+
30
+ // packages/core/src/scope.ts
31
+ var exports_scope = {};
32
+ __export(exports_scope, {
33
+ withScopeAsync: () => withScopeAsync,
34
+ withScope: () => withScope
35
+ });
36
+ module.exports = __toCommonJS(exports_scope);
37
+ function createScope() {
38
+ const handles = [];
39
+ return {
40
+ manage(handle) {
41
+ handles.push(handle);
42
+ return handle;
43
+ },
44
+ get handles() {
45
+ return handles;
46
+ }
47
+ };
48
+ }
49
+ function disposeScope(scope) {
50
+ const handles = scope.handles;
51
+ for (let i = handles.length - 1;i >= 0; i--) {
52
+ const handle = handles[i];
53
+ if (handle && handle.alive) {
54
+ handle.dispose();
55
+ }
56
+ }
57
+ }
58
+ function withScope(_context, fn) {
59
+ const scope = createScope();
60
+ try {
61
+ return fn(scope);
62
+ } finally {
63
+ disposeScope(scope);
64
+ }
65
+ }
66
+ async function withScopeAsync(_context, fn) {
67
+ const scope = createScope();
68
+ try {
69
+ return await fn(scope);
70
+ } finally {
71
+ disposeScope(scope);
72
+ }
73
+ }
74
+ })
75
+
76
+ //# debugId=C97AB5B520552F3B64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/scope.ts"],
4
+ "sourcesContent": [
5
+ "import type { QuickJSContext, QuickJSHandle } from \"quickjs-emscripten\";\nimport type { Scope } from \"./types.ts\";\n\n/**\n * Create a new scope for tracking handles\n */\nfunction createScope(): Scope {\n const handles: QuickJSHandle[] = [];\n\n return {\n manage<T extends QuickJSHandle>(handle: T): T {\n handles.push(handle);\n return handle;\n },\n get handles() {\n return handles as readonly QuickJSHandle[];\n },\n };\n}\n\n/**\n * Dispose all handles in a scope (in reverse order)\n */\nfunction disposeScope(scope: Scope): void {\n const handles = scope.handles;\n for (let i = handles.length - 1; i >= 0; i--) {\n const handle = handles[i];\n if (handle && handle.alive) {\n handle.dispose();\n }\n }\n}\n\n/**\n * Execute a function with automatic handle cleanup\n *\n * @example\n * const result = withScope(context, (scope) => {\n * const obj = scope.manage(context.newObject());\n * const str = scope.manage(context.newString(\"hello\"));\n * context.setProp(obj, \"message\", str);\n * return context.dump(obj);\n * });\n */\nexport function withScope<T>(\n _context: QuickJSContext,\n fn: (scope: Scope) => T\n): T {\n const scope = createScope();\n try {\n return fn(scope);\n } finally {\n disposeScope(scope);\n }\n}\n\n/**\n * Async version of withScope for promise-based operations\n */\nexport async function withScopeAsync<T>(\n _context: QuickJSContext,\n fn: (scope: Scope) => Promise<T>\n): Promise<T> {\n const scope = createScope();\n try {\n return await fn(scope);\n } finally {\n disposeScope(scope);\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,WAAW,GAAU;AAAA,EAC5B,MAAM,UAA2B,CAAC;AAAA,EAElC,OAAO;AAAA,IACL,MAA+B,CAAC,QAAc;AAAA,MAC5C,QAAQ,KAAK,MAAM;AAAA,MACnB,OAAO;AAAA;AAAA,QAEL,OAAO,GAAG;AAAA,MACZ,OAAO;AAAA;AAAA,EAEX;AAAA;AAMF,SAAS,YAAY,CAAC,OAAoB;AAAA,EACxC,MAAM,UAAU,MAAM;AAAA,EACtB,SAAS,IAAI,QAAQ,SAAS,EAAG,KAAK,GAAG,KAAK;AAAA,IAC5C,MAAM,SAAS,QAAQ;AAAA,IACvB,IAAI,UAAU,OAAO,OAAO;AAAA,MAC1B,OAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AAAA;AAcK,SAAS,SAAY,CAC1B,UACA,IACG;AAAA,EACH,MAAM,QAAQ,YAAY;AAAA,EAC1B,IAAI;AAAA,IACF,OAAO,GAAG,KAAK;AAAA,YACf;AAAA,IACA,aAAa,KAAK;AAAA;AAAA;AAOtB,eAAsB,cAAiB,CACrC,UACA,IACY;AAAA,EACZ,MAAM,QAAQ,YAAY;AAAA,EAC1B,IAAI;AAAA,IACF,OAAO,MAAM,GAAG,KAAK;AAAA,YACrB;AAAA,IACA,aAAa,KAAK;AAAA;AAAA;",
8
+ "debugId": "C97AB5B520552F3B64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,152 @@
1
+ // @bun @bun-cjs
2
+ (function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+
30
+ // packages/core/src/streams/transform-stream.ts
31
+ var exports_transform_stream = {};
32
+ __export(exports_transform_stream, {
33
+ createTransformStreamClass: () => createTransformStreamClass
34
+ });
35
+ module.exports = __toCommonJS(exports_transform_stream);
36
+ var import_class_builder = require("../class-builder.ts");
37
+ function createTransformStreamClass(context, stateMap) {
38
+ return import_class_builder.defineClass(context, stateMap, {
39
+ name: "TransformStream",
40
+ construct: (args) => {
41
+ const transformer = args[0];
42
+ const readableQueue = [];
43
+ let readableCloseRequested = false;
44
+ let readableClosed = false;
45
+ let readableErrored = false;
46
+ let readableErrorValue = undefined;
47
+ const controller = {
48
+ enqueue(chunk) {
49
+ if (readableCloseRequested || readableClosed) {
50
+ throw new TypeError("Readable side is closed");
51
+ }
52
+ readableQueue.push(chunk);
53
+ },
54
+ error(e) {
55
+ readableErrored = true;
56
+ readableErrorValue = e;
57
+ },
58
+ terminate() {
59
+ readableCloseRequested = true;
60
+ },
61
+ get desiredSize() {
62
+ if (readableErrored)
63
+ return null;
64
+ if (readableCloseRequested)
65
+ return 0;
66
+ return 1 - readableQueue.length;
67
+ }
68
+ };
69
+ const readableState = {
70
+ locked: false,
71
+ reader: null,
72
+ queue: readableQueue,
73
+ closeRequested: readableCloseRequested,
74
+ closed: readableClosed,
75
+ errored: readableErrored,
76
+ errorValue: readableErrorValue,
77
+ started: true,
78
+ controller: {
79
+ enqueue: controller.enqueue,
80
+ close: controller.terminate,
81
+ error: controller.error,
82
+ desiredSize: 1
83
+ }
84
+ };
85
+ const writableState = {
86
+ locked: false,
87
+ writer: null,
88
+ closed: false,
89
+ errored: false,
90
+ errorValue: undefined,
91
+ closeRequested: false,
92
+ writeRequests: [],
93
+ inFlightWriteRequest: null,
94
+ started: true,
95
+ controller: {
96
+ error: controller.error
97
+ },
98
+ sink: {
99
+ write: async (chunk) => {
100
+ if (transformer?.transform) {
101
+ await transformer.transform(chunk, controller);
102
+ } else {
103
+ controller.enqueue(chunk);
104
+ }
105
+ },
106
+ close: async () => {
107
+ if (transformer?.flush) {
108
+ await transformer.flush(controller);
109
+ }
110
+ controller.terminate();
111
+ }
112
+ }
113
+ };
114
+ const state = {
115
+ readable: readableState,
116
+ writable: writableState,
117
+ transformer,
118
+ controller,
119
+ backpressure: false,
120
+ backpressureChangePromise: null
121
+ };
122
+ if (transformer?.start) {
123
+ try {
124
+ const startResult = transformer.start(controller);
125
+ if (startResult instanceof Promise) {
126
+ startResult.catch((e) => {
127
+ controller.error(e);
128
+ });
129
+ }
130
+ } catch (e) {
131
+ controller.error(e);
132
+ }
133
+ }
134
+ return state;
135
+ },
136
+ properties: {
137
+ readable: {
138
+ get() {
139
+ return this.readable;
140
+ }
141
+ },
142
+ writable: {
143
+ get() {
144
+ return this.writable;
145
+ }
146
+ }
147
+ }
148
+ });
149
+ }
150
+ })
151
+
152
+ //# debugId=C4B9DC13F7F7B17D64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/streams/transform-stream.ts"],
4
+ "sourcesContent": [
5
+ "import type { QuickJSContext, QuickJSHandle } from \"quickjs-emscripten\";\nimport type { StateMap } from \"../types.ts\";\nimport { defineClass } from \"../class-builder.ts\";\nimport { marshal } from \"../marshal.ts\";\nimport { unmarshal } from \"../unmarshal.ts\";\n\ninterface TransformStreamController {\n enqueue(chunk: unknown): void;\n error(e: unknown): void;\n terminate(): void;\n desiredSize: number | null;\n}\n\ninterface TransformStreamInternalState {\n readable: object; // ReadableStream internal state\n writable: object; // WritableStream internal state\n transformer?: {\n start?: (controller: TransformStreamController) => void | Promise<void>;\n transform?: (chunk: unknown, controller: TransformStreamController) => void | Promise<void>;\n flush?: (controller: TransformStreamController) => void | Promise<void>;\n };\n controller: TransformStreamController;\n backpressure: boolean;\n backpressureChangePromise: {\n resolve: () => void;\n promise: Promise<void>;\n } | null;\n}\n\n/**\n * Create the TransformStream class\n */\nexport function createTransformStreamClass(\n context: QuickJSContext,\n stateMap: StateMap\n): QuickJSHandle {\n return defineClass<TransformStreamInternalState>(context, stateMap, {\n name: \"TransformStream\",\n construct: (args) => {\n const transformer = args[0] as {\n start?: (controller: TransformStreamController) => void | Promise<void>;\n transform?: (chunk: unknown, controller: TransformStreamController) => void | Promise<void>;\n flush?: (controller: TransformStreamController) => void | Promise<void>;\n } | undefined;\n\n // Queue for the readable side\n const readableQueue: unknown[] = [];\n let readableCloseRequested = false;\n let readableClosed = false;\n let readableErrored = false;\n let readableErrorValue: unknown = undefined;\n\n // Create controller\n const controller: TransformStreamController = {\n enqueue(chunk: unknown) {\n if (readableCloseRequested || readableClosed) {\n throw new TypeError(\"Readable side is closed\");\n }\n readableQueue.push(chunk);\n },\n error(e: unknown) {\n readableErrored = true;\n readableErrorValue = e;\n },\n terminate() {\n readableCloseRequested = true;\n },\n get desiredSize() {\n if (readableErrored) return null;\n if (readableCloseRequested) return 0;\n return 1 - readableQueue.length;\n },\n };\n\n // Create readable side state\n const readableState = {\n locked: false,\n reader: null,\n queue: readableQueue,\n closeRequested: readableCloseRequested,\n closed: readableClosed,\n errored: readableErrored,\n errorValue: readableErrorValue,\n started: true,\n controller: {\n enqueue: controller.enqueue,\n close: controller.terminate,\n error: controller.error,\n desiredSize: 1,\n },\n };\n\n // Create writable side state\n const writableState = {\n locked: false,\n writer: null,\n closed: false,\n errored: false,\n errorValue: undefined,\n closeRequested: false,\n writeRequests: [],\n inFlightWriteRequest: null,\n started: true,\n controller: {\n error: controller.error,\n },\n sink: {\n write: async (chunk: unknown) => {\n if (transformer?.transform) {\n await transformer.transform(chunk, controller);\n } else {\n // Default identity transform\n controller.enqueue(chunk);\n }\n },\n close: async () => {\n if (transformer?.flush) {\n await transformer.flush(controller);\n }\n controller.terminate();\n },\n },\n };\n\n const state: TransformStreamInternalState = {\n readable: readableState,\n writable: writableState,\n transformer,\n controller,\n backpressure: false,\n backpressureChangePromise: null,\n };\n\n // Call start if provided\n if (transformer?.start) {\n try {\n const startResult = transformer.start(controller);\n if (startResult instanceof Promise) {\n startResult.catch((e) => {\n controller.error(e);\n });\n }\n } catch (e) {\n controller.error(e);\n }\n }\n\n return state;\n },\n properties: {\n readable: {\n get(this: TransformStreamInternalState) {\n // Return the readable state - will be wrapped by the stream class\n return this.readable;\n },\n },\n writable: {\n get(this: TransformStreamInternalState) {\n // Return the writable state - will be wrapped by the stream class\n return this.writable;\n },\n },\n },\n });\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE4B,IAA5B;AA8BO,SAAS,0BAA0B,CACxC,SACA,UACe;AAAA,EACf,OAAO,iCAA0C,SAAS,UAAU;AAAA,IAClE,MAAM;AAAA,IACN,WAAW,CAAC,SAAS;AAAA,MACnB,MAAM,cAAc,KAAK;AAAA,MAOzB,MAAM,gBAA2B,CAAC;AAAA,MAClC,IAAI,yBAAyB;AAAA,MAC7B,IAAI,iBAAiB;AAAA,MACrB,IAAI,kBAAkB;AAAA,MACtB,IAAI,qBAA8B;AAAA,MAGlC,MAAM,aAAwC;AAAA,QAC5C,OAAO,CAAC,OAAgB;AAAA,UACtB,IAAI,0BAA0B,gBAAgB;AAAA,YAC5C,MAAM,IAAI,UAAU,yBAAyB;AAAA,UAC/C;AAAA,UACA,cAAc,KAAK,KAAK;AAAA;AAAA,QAE1B,KAAK,CAAC,GAAY;AAAA,UAChB,kBAAkB;AAAA,UAClB,qBAAqB;AAAA;AAAA,QAEvB,SAAS,GAAG;AAAA,UACV,yBAAyB;AAAA;AAAA,YAEvB,WAAW,GAAG;AAAA,UAChB,IAAI;AAAA,Y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AAuB,SAAS;AAAA,YAClC,YAAY,MAAM,CAAC,MAAM;AAAA,cACvB,WAAW,MAAM,CAAC;AAAA,aACnB;AAAA,UACH;AAAA,UACA,OAAO,GAAG;AAAA,UACV,WAAW,MAAM,CAAC;AAAA;AAAA,MAEtB;AAAA,MAEA,OAAO;AAAA;AAAA,IAET,YAAY;AAAA,MACV,UAAU;AAAA,QACR,GAAG,GAAqC;AAAA,UAEtC,OAAO,KAAK;AAAA;AAAA,MAEhB;AAAA,MACA,UAAU;AAAA,QACR,GAAG,GAAqC;AAAA,UAEtC,OAAO,KAAK;AAAA;AAAA,MAEhB;AAAA,IACF;AAAA,EACF,CAAC;AAAA;",
8
+ "debugId": "C4B9DC13F7F7B17D64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,39 @@
1
+ // @bun @bun-cjs
2
+ (function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+
30
+ // packages/core/src/types.ts
31
+ var exports_types = {};
32
+ __export(exports_types, {
33
+ INTERNAL_STATE: () => INTERNAL_STATE
34
+ });
35
+ module.exports = __toCommonJS(exports_types);
36
+ var INTERNAL_STATE = Symbol("INTERNAL_STATE");
37
+ })
38
+
39
+ //# debugId=1449C2F7927C25D664756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types.ts"],
4
+ "sourcesContent": [
5
+ "import type {\n QuickJSContext,\n QuickJSHandle,\n QuickJSRuntime,\n} from \"quickjs-emscripten\";\n\nexport type { QuickJSContext, QuickJSHandle, QuickJSRuntime };\n\n/**\n * A scope for automatic handle cleanup\n */\nexport interface Scope {\n /** Track a handle for cleanup when scope ends */\n manage<T extends QuickJSHandle>(handle: T): T;\n\n /** Get all managed handles */\n readonly handles: readonly QuickJSHandle[];\n}\n\n/**\n * Options for marshalling values\n */\nexport interface MarshalOptions {\n /** Maximum depth for nested objects (default: 10) */\n maxDepth?: number;\n\n /** Custom marshaller for specific types */\n custom?: (value: unknown, context: QuickJSContext) => QuickJSHandle | undefined;\n}\n\n/**\n * Options for unmarshalling values\n */\nexport interface UnmarshalOptions {\n /** Maximum depth for nested objects (default: 10) */\n maxDepth?: number;\n\n /** Custom unmarshaller for specific handles */\n custom?: (handle: QuickJSHandle, context: QuickJSContext) => unknown | undefined;\n}\n\n/**\n * Property descriptor for class builder\n */\nexport interface PropertyDescriptor<TState = unknown> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get?: (this: TState) => any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n set?: (this: TState, value: any) => void;\n value?: unknown;\n writable?: boolean;\n enumerable?: boolean;\n configurable?: boolean;\n}\n\n/**\n * Options for defining a class\n */\nexport interface ClassDefinition<TState extends object = object> {\n /** Class name */\n name: string;\n\n /** Constructor function - receives unmarshalled args, returns internal state */\n construct?: (args: unknown[]) => TState;\n\n /** Prototype methods */\n methods?: Record<string, (this: TState, ...args: unknown[]) => unknown>;\n\n /** Prototype getters/setters */\n properties?: Record<string, PropertyDescriptor<TState>>;\n\n /** Static methods */\n staticMethods?: Record<string, (...args: unknown[]) => unknown>;\n\n /** Static properties */\n staticProperties?: Record<string, unknown>;\n\n /** Parent class handle (for inheritance) */\n extends?: QuickJSHandle;\n}\n\n/**\n * Symbol used to store internal state on QuickJS class instances\n */\nexport const INTERNAL_STATE: unique symbol = Symbol(\"INTERNAL_STATE\");\n\n/**\n * Map to store internal state for QuickJS object handles\n */\nexport type StateMap = WeakMap<QuickJSHandle, object>;\n\n/**\n * Options for setting up core APIs\n */\nexport interface SetupCoreOptions {\n /** Existing state map to use (creates new one if not provided) */\n stateMap?: StateMap;\n}\n\n/**\n * Handle returned from setupCore\n */\nexport interface CoreHandle {\n /** State map containing internal states */\n readonly stateMap: StateMap;\n\n /** Dispose all handles */\n dispose(): void;\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFO,IAAM,iBAAgC,OAAO,gBAAgB;",
8
+ "debugId": "1449C2F7927C25D664756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,254 @@
1
+ // @bun @bun-cjs
2
+ (function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+
30
+ // packages/core/src/unmarshal.ts
31
+ var exports_unmarshal = {};
32
+ __export(exports_unmarshal, {
33
+ unmarshal: () => unmarshal,
34
+ cleanupUnmarshaledHandles: () => cleanupUnmarshaledHandles
35
+ });
36
+ module.exports = __toCommonJS(exports_unmarshal);
37
+ var import_marshal = require("./marshal.ts");
38
+ var contextDupedHandles = new WeakMap;
39
+ function getDupedHandles(context) {
40
+ let handles = contextDupedHandles.get(context);
41
+ if (!handles) {
42
+ handles = new Set;
43
+ contextDupedHandles.set(context, handles);
44
+ }
45
+ return handles;
46
+ }
47
+ function cleanupUnmarshaledHandles(context) {
48
+ const handles = contextDupedHandles.get(context);
49
+ if (handles) {
50
+ for (const handle of handles) {
51
+ try {
52
+ handle.dispose();
53
+ } catch {}
54
+ }
55
+ handles.clear();
56
+ contextDupedHandles.delete(context);
57
+ }
58
+ }
59
+ function unmarshal(context, handle, options = {}) {
60
+ const maxDepth = options.maxDepth ?? 10;
61
+ const seen = new WeakMap;
62
+ function unmarshalValue(h, depth) {
63
+ if (depth > maxDepth) {
64
+ throw new Error(`Maximum unmarshalling depth of ${maxDepth} exceeded`);
65
+ }
66
+ if (options.custom) {
67
+ const customResult = options.custom(h, context);
68
+ if (customResult !== undefined) {
69
+ return customResult;
70
+ }
71
+ }
72
+ const type = context.typeof(h);
73
+ if (type === "undefined") {
74
+ return;
75
+ }
76
+ const dumpedValue = context.dump(h);
77
+ if (dumpedValue === null) {
78
+ return null;
79
+ }
80
+ if (type === "boolean") {
81
+ return dumpedValue;
82
+ }
83
+ if (type === "number") {
84
+ return dumpedValue;
85
+ }
86
+ if (type === "string") {
87
+ return dumpedValue;
88
+ }
89
+ if (typeof dumpedValue === "bigint") {
90
+ return dumpedValue;
91
+ }
92
+ if (type === "function") {
93
+ const fnHandle = h.dup();
94
+ getDupedHandles(context).add(fnHandle);
95
+ const wrapper = (...args) => {
96
+ const argHandles = args.map((arg) => import_marshal.marshal(context, arg));
97
+ try {
98
+ const result = context.callFunction(fnHandle, context.undefined, ...argHandles);
99
+ if (result.error) {
100
+ const errorValue = context.dump(result.error);
101
+ result.error.dispose();
102
+ throw new Error(typeof errorValue === "object" && errorValue !== null ? errorValue.message || String(errorValue) : String(errorValue));
103
+ }
104
+ const value = unmarshalValue(result.value, depth + 1);
105
+ result.value.dispose();
106
+ return value;
107
+ } finally {
108
+ for (const argHandle of argHandles) {
109
+ argHandle.dispose();
110
+ }
111
+ }
112
+ };
113
+ wrapper.__dispose__ = () => {
114
+ fnHandle.dispose();
115
+ };
116
+ return wrapper;
117
+ }
118
+ if (type === "object") {
119
+ if (seen.has(h)) {
120
+ return seen.get(h);
121
+ }
122
+ const lengthHandle = context.getProp(h, "length");
123
+ const lengthType = context.typeof(lengthHandle);
124
+ lengthHandle.dispose();
125
+ if (lengthType === "number") {
126
+ const arrayIsArray = context.getProp(context.global, "Array");
127
+ const isArrayFn = context.getProp(arrayIsArray, "isArray");
128
+ const isArrayResult = context.callFunction(isArrayFn, context.undefined, h);
129
+ arrayIsArray.dispose();
130
+ isArrayFn.dispose();
131
+ let isArray = false;
132
+ if (!isArrayResult.error) {
133
+ isArray = context.dump(isArrayResult.value) === true;
134
+ isArrayResult.value.dispose();
135
+ } else {
136
+ isArrayResult.error.dispose();
137
+ }
138
+ if (isArray) {
139
+ const arr = [];
140
+ seen.set(h, arr);
141
+ const len = context.getNumber(context.getProp(h, "length"));
142
+ const lenHandle = context.getProp(h, "length");
143
+ const length = context.getNumber(lenHandle);
144
+ lenHandle.dispose();
145
+ for (let i = 0;i < length; i++) {
146
+ const elementHandle = context.getProp(h, i);
147
+ arr[i] = unmarshalValue(elementHandle, depth + 1);
148
+ elementHandle.dispose();
149
+ }
150
+ return arr;
151
+ }
152
+ }
153
+ const dateConstructor = context.getProp(context.global, "Date");
154
+ const isDateResult = context.evalCode(`(function(obj, Date) { return obj instanceof Date; })`);
155
+ if (!isDateResult.error) {
156
+ const checkResult = context.callFunction(isDateResult.value, context.undefined, h, dateConstructor);
157
+ isDateResult.value.dispose();
158
+ if (!checkResult.error && context.dump(checkResult.value) === true) {
159
+ checkResult.value.dispose();
160
+ dateConstructor.dispose();
161
+ const getTimeHandle = context.getProp(h, "getTime");
162
+ const timeResult = context.callFunction(getTimeHandle, h);
163
+ getTimeHandle.dispose();
164
+ if (!timeResult.error) {
165
+ const timestamp = context.getNumber(timeResult.value);
166
+ timeResult.value.dispose();
167
+ return new Date(timestamp);
168
+ }
169
+ if (timeResult.error)
170
+ timeResult.error.dispose();
171
+ }
172
+ if (checkResult.error)
173
+ checkResult.error.dispose();
174
+ else if (checkResult.value)
175
+ checkResult.value.dispose();
176
+ } else {
177
+ isDateResult.error.dispose();
178
+ }
179
+ dateConstructor.dispose();
180
+ const uint8ArrayConstructor = context.getProp(context.global, "Uint8Array");
181
+ const isUint8ArrayResult = context.evalCode(`(function(obj, U8) { return obj instanceof U8; })`);
182
+ if (!isUint8ArrayResult.error) {
183
+ const checkResult = context.callFunction(isUint8ArrayResult.value, context.undefined, h, uint8ArrayConstructor);
184
+ isUint8ArrayResult.value.dispose();
185
+ if (!checkResult.error && context.dump(checkResult.value) === true) {
186
+ checkResult.value.dispose();
187
+ uint8ArrayConstructor.dispose();
188
+ const arrayBuffer = context.getArrayBuffer(h);
189
+ if (arrayBuffer) {
190
+ return new Uint8Array(arrayBuffer.value);
191
+ }
192
+ } else {
193
+ if (checkResult.error)
194
+ checkResult.error.dispose();
195
+ else
196
+ checkResult.value.dispose();
197
+ uint8ArrayConstructor.dispose();
198
+ }
199
+ } else {
200
+ isUint8ArrayResult.error.dispose();
201
+ uint8ArrayConstructor.dispose();
202
+ }
203
+ const arrayBufferConstructor = context.getProp(context.global, "ArrayBuffer");
204
+ const isArrayBufferResult = context.evalCode(`(function(obj, AB) { return obj instanceof AB; })`);
205
+ if (!isArrayBufferResult.error) {
206
+ const checkResult = context.callFunction(isArrayBufferResult.value, context.undefined, h, arrayBufferConstructor);
207
+ isArrayBufferResult.value.dispose();
208
+ if (!checkResult.error && context.dump(checkResult.value) === true) {
209
+ checkResult.value.dispose();
210
+ arrayBufferConstructor.dispose();
211
+ const arrayBuffer = context.getArrayBuffer(h);
212
+ if (arrayBuffer) {
213
+ return arrayBuffer.value.slice(0);
214
+ }
215
+ } else {
216
+ if (checkResult.error)
217
+ checkResult.error.dispose();
218
+ else
219
+ checkResult.value.dispose();
220
+ arrayBufferConstructor.dispose();
221
+ }
222
+ } else {
223
+ isArrayBufferResult.error.dispose();
224
+ arrayBufferConstructor.dispose();
225
+ }
226
+ const obj = {};
227
+ seen.set(h, obj);
228
+ const keysResult = context.evalCode(`(function(obj) { return Object.keys(obj); })`);
229
+ if (!keysResult.error) {
230
+ const keysArrayHandle = context.callFunction(keysResult.value, context.undefined, h);
231
+ keysResult.value.dispose();
232
+ if (!keysArrayHandle.error) {
233
+ const keysArray = unmarshalValue(keysArrayHandle.value, depth + 1);
234
+ keysArrayHandle.value.dispose();
235
+ for (const key of keysArray) {
236
+ const propHandle = context.getProp(h, key);
237
+ obj[key] = unmarshalValue(propHandle, depth + 1);
238
+ propHandle.dispose();
239
+ }
240
+ } else {
241
+ keysArrayHandle.error.dispose();
242
+ }
243
+ } else {
244
+ keysResult.error.dispose();
245
+ }
246
+ return obj;
247
+ }
248
+ return dumpedValue;
249
+ }
250
+ return unmarshalValue(handle, 0);
251
+ }
252
+ })
253
+
254
+ //# debugId=B57FBFC1AF15EE0664756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/unmarshal.ts"],
4
+ "sourcesContent": [
5
+ "import type { QuickJSContext, QuickJSHandle } from \"quickjs-emscripten\";\nimport type { UnmarshalOptions } from \"./types.ts\";\nimport { marshal } from \"./marshal.ts\";\n\n// Track duped handles per context so they can be cleaned up\nconst contextDupedHandles = new WeakMap<QuickJSContext, Set<QuickJSHandle>>();\n\n/**\n * Get or create the set of duped handles for a context\n */\nfunction getDupedHandles(context: QuickJSContext): Set<QuickJSHandle> {\n let handles = contextDupedHandles.get(context);\n if (!handles) {\n handles = new Set();\n contextDupedHandles.set(context, handles);\n }\n return handles;\n}\n\n/**\n * Clean up all duped handles for a context\n * Should be called before disposing the context\n */\nexport function cleanupUnmarshaledHandles(context: QuickJSContext): void {\n const handles = contextDupedHandles.get(context);\n if (handles) {\n for (const handle of handles) {\n try {\n handle.dispose();\n } catch {\n // Handle may already be disposed\n }\n }\n handles.clear();\n contextDupedHandles.delete(context);\n }\n}\n\n/**\n * Unmarshal a QuickJS handle to a JavaScript value\n *\n * @example\n * const value = unmarshal(context, handle);\n */\nexport function unmarshal(\n context: QuickJSContext,\n handle: QuickJSHandle,\n options: UnmarshalOptions = {}\n): unknown {\n const maxDepth = options.maxDepth ?? 10;\n const seen = new WeakMap<QuickJSHandle, object>();\n\n function unmarshalValue(h: QuickJSHandle, depth: number): unknown {\n if (depth > maxDepth) {\n throw new Error(`Maximum unmarshalling depth of ${maxDepth} exceeded`);\n }\n\n // Try custom unmarshaller first\n if (options.custom) {\n const customResult = options.custom(h, context);\n if (customResult !== undefined) {\n return customResult;\n }\n }\n\n const type = context.typeof(h);\n\n // Handle primitives\n if (type === \"undefined\") {\n return undefined;\n }\n\n // Check for null (typeof returns \"object\" for null)\n const dumpedValue = context.dump(h);\n if (dumpedValue === null) {\n return null;\n }\n\n if (type === \"boolean\") {\n return dumpedValue as boolean;\n }\n if (type === \"number\") {\n return dumpedValue as number;\n }\n if (type === \"string\") {\n return dumpedValue as string;\n }\n\n // Handle bigint\n if (typeof dumpedValue === \"bigint\") {\n return dumpedValue;\n }\n\n // Handle functions - return a wrapper that calls back into QuickJS\n if (type === \"function\") {\n // Dup the handle so it stays alive after unmarshalling\n // This is necessary because the caller may dispose the original handle\n const fnHandle = h.dup();\n // Track the duped handle for cleanup\n getDupedHandles(context).add(fnHandle);\n const wrapper = (...args: unknown[]) => {\n const argHandles = args.map((arg) => marshal(context, arg));\n try {\n const result = context.callFunction(fnHandle, context.undefined, ...argHandles);\n if (result.error) {\n const errorValue = context.dump(result.error);\n result.error.dispose();\n throw new Error(\n typeof errorValue === \"object\" && errorValue !== null\n ? (errorValue as { message?: string }).message || String(errorValue)\n : String(errorValue)\n );\n }\n const value = unmarshalValue(result.value, depth + 1);\n result.value.dispose();\n return value;\n } finally {\n for (const argHandle of argHandles) {\n argHandle.dispose();\n }\n }\n };\n // Attach a dispose method to clean up the handle when the function is no longer needed\n (wrapper as unknown as { __dispose__: () => void }).__dispose__ = () => {\n fnHandle.dispose();\n };\n return wrapper;\n }\n\n // Handle objects\n if (type === \"object\") {\n // Check for circular reference\n if (seen.has(h)) {\n return seen.get(h);\n }\n\n // Check if it's an array\n const lengthHandle = context.getProp(h, \"length\");\n const lengthType = context.typeof(lengthHandle);\n lengthHandle.dispose();\n\n if (lengthType === \"number\") {\n // Check for Array by looking for Array.isArray\n const arrayIsArray = context.getProp(context.global, \"Array\");\n const isArrayFn = context.getProp(arrayIsArray, \"isArray\");\n const isArrayResult = context.callFunction(isArrayFn, context.undefined, h);\n arrayIsArray.dispose();\n isArrayFn.dispose();\n\n let isArray = false;\n if (!isArrayResult.error) {\n isArray = context.dump(isArrayResult.value) === true;\n isArrayResult.value.dispose();\n } else {\n isArrayResult.error.dispose();\n }\n\n if (isArray) {\n const arr: unknown[] = [];\n seen.set(h, arr);\n\n const len = context.getNumber(context.getProp(h, \"length\"));\n const lenHandle = context.getProp(h, \"length\");\n const length = context.getNumber(lenHandle);\n lenHandle.dispose();\n\n for (let i = 0; i < length; i++) {\n const elementHandle = context.getProp(h, i);\n arr[i] = unmarshalValue(elementHandle, depth + 1);\n elementHandle.dispose();\n }\n return arr;\n }\n }\n\n // Check if it's a Date\n const dateConstructor = context.getProp(context.global, \"Date\");\n const isDateResult = context.evalCode(`(function(obj, Date) { return obj instanceof Date; })`);\n if (!isDateResult.error) {\n const checkResult = context.callFunction(\n isDateResult.value,\n context.undefined,\n h,\n dateConstructor\n );\n isDateResult.value.dispose();\n\n if (!checkResult.error && context.dump(checkResult.value) === true) {\n checkResult.value.dispose();\n dateConstructor.dispose();\n\n const getTimeHandle = context.getProp(h, \"getTime\");\n const timeResult = context.callFunction(getTimeHandle, h);\n getTimeHandle.dispose();\n\n if (!timeResult.error) {\n const timestamp = context.getNumber(timeResult.value);\n timeResult.value.dispose();\n return new Date(timestamp);\n }\n if (timeResult.error) timeResult.error.dispose();\n }\n if (checkResult.error) checkResult.error.dispose();\n else if (checkResult.value) checkResult.value.dispose();\n } else {\n isDateResult.error.dispose();\n }\n dateConstructor.dispose();\n\n // Check if it's a Uint8Array\n const uint8ArrayConstructor = context.getProp(context.global, \"Uint8Array\");\n const isUint8ArrayResult = context.evalCode(`(function(obj, U8) { return obj instanceof U8; })`);\n if (!isUint8ArrayResult.error) {\n const checkResult = context.callFunction(\n isUint8ArrayResult.value,\n context.undefined,\n h,\n uint8ArrayConstructor\n );\n isUint8ArrayResult.value.dispose();\n\n if (!checkResult.error && context.dump(checkResult.value) === true) {\n checkResult.value.dispose();\n uint8ArrayConstructor.dispose();\n\n // Get the Uint8Array bytes\n const arrayBuffer = context.getArrayBuffer(h);\n if (arrayBuffer) {\n return new Uint8Array(arrayBuffer.value);\n }\n // Fall through to plain object handling if getArrayBuffer fails\n } else {\n if (checkResult.error) checkResult.error.dispose();\n else checkResult.value.dispose();\n uint8ArrayConstructor.dispose();\n }\n } else {\n isUint8ArrayResult.error.dispose();\n uint8ArrayConstructor.dispose();\n }\n\n // Check if it's an ArrayBuffer\n const arrayBufferConstructor = context.getProp(context.global, \"ArrayBuffer\");\n const isArrayBufferResult = context.evalCode(`(function(obj, AB) { return obj instanceof AB; })`);\n if (!isArrayBufferResult.error) {\n const checkResult = context.callFunction(\n isArrayBufferResult.value,\n context.undefined,\n h,\n arrayBufferConstructor\n );\n isArrayBufferResult.value.dispose();\n\n if (!checkResult.error && context.dump(checkResult.value) === true) {\n checkResult.value.dispose();\n arrayBufferConstructor.dispose();\n\n // Get the ArrayBuffer bytes directly\n const arrayBuffer = context.getArrayBuffer(h);\n if (arrayBuffer) {\n return arrayBuffer.value.slice(0);\n }\n // Fall through to plain object handling if getArrayBuffer fails\n } else {\n if (checkResult.error) checkResult.error.dispose();\n else checkResult.value.dispose();\n arrayBufferConstructor.dispose();\n }\n } else {\n isArrayBufferResult.error.dispose();\n arrayBufferConstructor.dispose();\n }\n\n // Plain object\n const obj: Record<string, unknown> = {};\n seen.set(h, obj);\n\n // Get own enumerable properties\n const keysResult = context.evalCode(`(function(obj) { return Object.keys(obj); })`);\n if (!keysResult.error) {\n const keysArrayHandle = context.callFunction(keysResult.value, context.undefined, h);\n keysResult.value.dispose();\n\n if (!keysArrayHandle.error) {\n const keysArray = unmarshalValue(keysArrayHandle.value, depth + 1) as string[];\n keysArrayHandle.value.dispose();\n\n for (const key of keysArray) {\n const propHandle = context.getProp(h, key);\n obj[key] = unmarshalValue(propHandle, depth + 1);\n propHandle.dispose();\n }\n } else {\n keysArrayHandle.error.dispose();\n }\n } else {\n keysResult.error.dispose();\n }\n\n return obj;\n }\n\n // Fallback to dump for unknown types\n return dumpedValue;\n }\n\n return unmarshalValue(handle, 0);\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEwB,IAAxB;AAGA,IAAM,sBAAsB,IAAI;AAKhC,SAAS,eAAe,CAAC,SAA6C;AAAA,EACpE,IAAI,UAAU,oBAAoB,IAAI,OAAO;AAAA,EAC7C,IAAI,CAAC,SAAS;AAAA,IACZ,UAAU,IAAI;AAAA,IACd,oBAAoB,IAAI,SAAS,OAAO;AAAA,EAC1C;AAAA,EACA,OAAO;AAAA;AAOF,SAAS,yBAAyB,CAAC,SAA+B;AAAA,EACvE,MAAM,UAAU,oBAAoB,IAAI,OAAO;AAAA,EAC/C,IAAI,SAAS;AAAA,IACX,WAAW,UAAU,SAAS;AAAA,MAC5B,IAA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