titanpl 6.0.0 → 7.0.0
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 +2 -6
- package/packages/cli/index.js +25 -11
- package/packages/cli/package.json +4 -4
- package/packages/cli/src/commands/build-ext.js +157 -0
- package/packages/cli/src/commands/build.js +12 -0
- package/packages/cli/src/commands/create.js +160 -0
- package/packages/cli/src/commands/init.js +5 -11
- package/packages/cli/src/commands/run-ext.js +104 -0
- package/{titanpl-sdk → packages/core-source}/LICENSE +1 -1
- package/packages/core-source/README.md +128 -0
- package/packages/core-source/V8_SERIALIZATION.md +125 -0
- package/packages/core-source/configure.js +50 -0
- package/packages/core-source/globals.d.ts +2238 -0
- package/packages/core-source/index.d.ts +515 -0
- package/packages/core-source/index.js +639 -0
- package/packages/core-source/jsconfig.json +12 -0
- package/packages/core-source/mkctx.config.json +7 -0
- package/packages/core-source/native/Cargo.lock +1559 -0
- package/packages/core-source/native/Cargo.toml +30 -0
- package/packages/core-source/native/src/crypto_impl.rs +139 -0
- package/packages/core-source/native/src/lib.rs +702 -0
- package/packages/core-source/native/src/storage_impl.rs +73 -0
- package/packages/core-source/native/src/v8_impl.rs +93 -0
- package/packages/core-source/package-lock.json +1464 -0
- package/packages/core-source/package.json +53 -0
- package/packages/core-source/tests/buffer.test.js +78 -0
- package/packages/core-source/tests/cookies.test.js +117 -0
- package/packages/core-source/tests/crypto.test.js +142 -0
- package/packages/core-source/tests/fs.test.js +176 -0
- package/packages/core-source/tests/ls.test.js +149 -0
- package/packages/core-source/tests/net.test.js +84 -0
- package/packages/core-source/tests/os.test.js +81 -0
- package/packages/core-source/tests/path.test.js +102 -0
- package/packages/core-source/tests/response.test.js +146 -0
- package/packages/core-source/tests/session.test.js +110 -0
- package/packages/core-source/tests/setup.js +325 -0
- package/packages/core-source/tests/time.test.js +57 -0
- package/packages/core-source/tests/url.test.js +82 -0
- package/packages/core-source/titan-ext.d.ts +2 -0
- package/packages/core-source/titan.json +9 -0
- package/packages/core-source/vitest.config.js +8 -0
- package/packages/engine-darwin-arm64/README.md +0 -2
- package/packages/engine-darwin-arm64/package.json +1 -1
- package/packages/engine-linux-x64/README.md +0 -2
- package/packages/engine-linux-x64/package.json +1 -1
- package/packages/engine-win32-x64/README.md +0 -1
- package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
- package/packages/engine-win32-x64/package.json +1 -1
- package/packages/native/README.md +0 -1
- package/packages/native/index.d.ts +25 -4
- package/packages/native/index.js +7 -0
- package/packages/native/package.json +2 -2
- package/packages/native/t.native.d.ts +167 -2
- package/packages/packet/index.js +103 -94
- package/packages/packet/package.json +1 -1
- package/packages/route/package.json +1 -1
- package/packages/sdk/index.js +2 -0
- package/packages/sdk/package.json +18 -0
- package/packages/sdk/test/index.js +120 -0
- package/templates/common/_tanfig.json +19 -13
- package/templates/extension/index.d.ts +26 -22
- package/templates/extension/index.js +15 -15
- package/templates/extension/native/Cargo.toml +5 -3
- package/templates/extension/native/src/lib.rs +2 -3
- package/templates/extension/package.json +10 -20
- package/templates/extension/titan.json +5 -16
- package/templates/extension/utils/registerExtension.js +44 -0
- package/templates/js/package.json +8 -8
- package/templates/rust-js/package.json +5 -5
- package/templates/rust-ts/package.json +5 -5
- package/templates/ts/package.json +8 -8
- package/packages/packet/node_modules/typescript/LICENSE.txt +0 -55
- package/packages/packet/node_modules/typescript/README.md +0 -50
- package/packages/packet/node_modules/typescript/SECURITY.md +0 -41
- package/packages/packet/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
- package/packages/packet/node_modules/typescript/bin/tsc +0 -2
- package/packages/packet/node_modules/typescript/bin/tsserver +0 -2
- package/packages/packet/node_modules/typescript/lib/_tsc.js +0 -133818
- package/packages/packet/node_modules/typescript/lib/_tsserver.js +0 -659
- package/packages/packet/node_modules/typescript/lib/_typingsInstaller.js +0 -222
- package/packages/packet/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/lib.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.decorators.d.ts +0 -384
- package/packages/packet/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.dom.d.ts +0 -39429
- package/packages/packet/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -571
- package/packages/packet/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -147
- package/packages/packet/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -597
- package/packages/packet/node_modules/typescript/lib/lib.es2015.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -605
- package/packages/packet/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -81
- package/packages/packet/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -128
- package/packages/packet/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -144
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -46
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -326
- package/packages/packet/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -116
- package/packages/packet/node_modules/typescript/lib/lib.es2016.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2017.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -49
- package/packages/packet/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -135
- package/packages/packet/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -45
- package/packages/packet/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -83
- package/packages/packet/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -30
- package/packages/packet/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -79
- package/packages/packet/node_modules/typescript/lib/lib.es2019.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -765
- package/packages/packet/node_modules/typescript/lib/lib.es2020.d.ts +0 -27
- package/packages/packet/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -42
- package/packages/packet/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -474
- package/packages/packet/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -47
- package/packages/packet/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -99
- package/packages/packet/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.es2021.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -166
- package/packages/packet/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -48
- package/packages/packet/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -78
- package/packages/packet/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -121
- package/packages/packet/node_modules/typescript/lib/lib.es2022.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -75
- package/packages/packet/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -145
- package/packages/packet/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -39
- package/packages/packet/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -924
- package/packages/packet/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2023.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -56
- package/packages/packet/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -65
- package/packages/packet/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -68
- package/packages/packet/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es5.d.ts +0 -4601
- package/packages/packet/node_modules/typescript/lib/lib.es6.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -96
- package/packages/packet/node_modules/typescript/lib/lib.esnext.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -193
- package/packages/packet/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.float16.d.ts +0 -445
- package/packages/packet/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.esnext.iterator.d.ts +0 -148
- package/packages/packet/node_modules/typescript/lib/lib.esnext.promise.d.ts +0 -34
- package/packages/packet/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.scripthost.d.ts +0 -322
- package/packages/packet/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.webworker.d.ts +0 -13150
- package/packages/packet/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -340
- package/packages/packet/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tsc.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserver.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/packages/packet/node_modules/typescript/lib/typesMap.json +0 -497
- package/packages/packet/node_modules/typescript/lib/typescript.d.ts +0 -11437
- package/packages/packet/node_modules/typescript/lib/typescript.js +0 -200276
- package/packages/packet/node_modules/typescript/lib/typingsInstaller.js +0 -8
- package/packages/packet/node_modules/typescript/lib/watchGuard.js +0 -53
- package/packages/packet/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/package.json +0 -120
- package/titanpl-sdk/README.md +0 -111
- package/titanpl-sdk/assets/titanpl-sdk.png +0 -0
- package/titanpl-sdk/bin/run.js +0 -274
- package/titanpl-sdk/index.js +0 -5
- package/titanpl-sdk/package-lock.json +0 -28
- package/titanpl-sdk/package.json +0 -40
- package/titanpl-sdk/templates/app/actions/hello.js +0 -5
- package/titanpl-sdk/templates/app/app.js +0 -7
- package/titanpl-sdk/templates/jsconfig.json +0 -19
- package/titanpl-sdk/templates/server/Cargo.toml +0 -52
- package/titanpl-sdk/templates/server/src/action_management.rs +0 -175
- package/titanpl-sdk/templates/server/src/errors.rs +0 -12
- package/titanpl-sdk/templates/server/src/extensions/builtin.rs +0 -1060
- package/titanpl-sdk/templates/server/src/extensions/external.rs +0 -338
- package/titanpl-sdk/templates/server/src/extensions/mod.rs +0 -580
- package/titanpl-sdk/templates/server/src/extensions/titan_core.js +0 -249
- package/titanpl-sdk/templates/server/src/fast_path.rs +0 -719
- package/titanpl-sdk/templates/server/src/main.rs +0 -607
- package/titanpl-sdk/templates/server/src/runtime.rs +0 -284
- package/titanpl-sdk/templates/server/src/utils.rs +0 -33
- package/titanpl-sdk/templates/titan/bundle.js +0 -259
- package/titanpl-sdk/templates/titan/dev.js +0 -390
- package/titanpl-sdk/templates/titan/error-box.js +0 -277
- package/titanpl-sdk/templates/titan/titan.js +0 -129
|
@@ -233,6 +233,34 @@ export const password: typeof t.password;
|
|
|
233
233
|
*/
|
|
234
234
|
export const db: typeof t.db;
|
|
235
235
|
|
|
236
|
+
/**
|
|
237
|
+
* WebSocket communication utilities.
|
|
238
|
+
*
|
|
239
|
+
* Re-exported from the `t` global for module-style imports.
|
|
240
|
+
* @see {@link TitanRuntimeUtils.ws} for full documentation.
|
|
241
|
+
*/
|
|
242
|
+
export const ws: typeof t.ws;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Binary serialization using V8's fast format.
|
|
246
|
+
*
|
|
247
|
+
* Re-exported from the `t` global for module-style imports.
|
|
248
|
+
* @see {@link TitanRuntimeUtils.serialize}
|
|
249
|
+
*/
|
|
250
|
+
export const serialize: typeof t.serialize;
|
|
251
|
+
/** Alias for serialize. @see {@link TitanRuntimeUtils.serialise} */
|
|
252
|
+
export const serialise: typeof t.serialise;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Binary deserialization for V8 buffers.
|
|
256
|
+
*
|
|
257
|
+
* Re-exported from the `t` global for module-style imports.
|
|
258
|
+
* @see {@link TitanRuntimeUtils.deserialize}
|
|
259
|
+
*/
|
|
260
|
+
export const deserialize: typeof t.deserialize;
|
|
261
|
+
/** Alias for deserialize. @see {@link TitanRuntimeUtils.deserialise} */
|
|
262
|
+
export const deserialise: typeof t.deserialise;
|
|
263
|
+
|
|
236
264
|
/**
|
|
237
265
|
* Async file system operations (read, write, mkdir, stat, etc.).
|
|
238
266
|
*
|
|
@@ -297,6 +325,14 @@ export const session: typeof t.session;
|
|
|
297
325
|
*/
|
|
298
326
|
export const cookies: typeof t.cookies;
|
|
299
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Titan Shared Context (Shared In-Memory State) shorthand.
|
|
330
|
+
*
|
|
331
|
+
* Re-exported from the `t` global for module-style imports.
|
|
332
|
+
* @see {@link TitanCore.ShareContext} for full documentation.
|
|
333
|
+
*/
|
|
334
|
+
export const shareContext: typeof t.shareContext;
|
|
335
|
+
|
|
300
336
|
/**
|
|
301
337
|
* Operating system information (platform, CPU count, memory).
|
|
302
338
|
*
|
|
@@ -639,6 +675,55 @@ declare global {
|
|
|
639
675
|
body?: string;
|
|
640
676
|
error?: string;
|
|
641
677
|
}>;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Fast binary serialization using V8's internal value format.
|
|
681
|
+
*
|
|
682
|
+
* Highly efficient for complex JavaScript objects including `Date`, `Map`,
|
|
683
|
+
* `Set`, and `TypedArrays`. The resulting `Uint8Array` is stable and
|
|
684
|
+
* can be safely stored in databases (e.g. `t.ls`) or transmitted.
|
|
685
|
+
*
|
|
686
|
+
* @param value - The JavaScript value/object to serialize.
|
|
687
|
+
* @returns A `Uint8Array` containing the binary-serialized representation.
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```js
|
|
691
|
+
* const complex = { date: new Date(), map: new Map([["a", 1]]) };
|
|
692
|
+
* const bytes = t.serialize(complex);
|
|
693
|
+
* // Store bytes in database or pass to another action
|
|
694
|
+
* ```
|
|
695
|
+
*/
|
|
696
|
+
serialize(value: any): Uint8Array;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Binary serialization. Alias for `t.serialize`.
|
|
700
|
+
* @see {@link TitanRuntimeUtils.serialize}
|
|
701
|
+
*/
|
|
702
|
+
serialise(value: any): Uint8Array;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Deserializes a binary buffer back into its original JavaScript value.
|
|
706
|
+
*
|
|
707
|
+
* Restores full object fidelity including native types like `Date` and `Buffer`.
|
|
708
|
+
* Performance is significantly faster than `JSON.parse` for large objects.
|
|
709
|
+
*
|
|
710
|
+
* @param buffer - A `Uint8Array` created by `t.serialize()`.
|
|
711
|
+
* @returns The restored JavaScript value or object.
|
|
712
|
+
* @throws If the buffer is invalid or contains corrupted V8 header data.
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* ```js
|
|
716
|
+
* const restored = t.deserialize(bytes);
|
|
717
|
+
* console.log(restored.date instanceof Date); // true
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
720
|
+
deserialize(buffer: Uint8Array): any;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Binary deserialization. Alias for `t.deserialize`.
|
|
724
|
+
* @see {@link TitanRuntimeUtils.deserialize}
|
|
725
|
+
*/
|
|
726
|
+
deserialise(buffer: Uint8Array): any;
|
|
642
727
|
|
|
643
728
|
/**
|
|
644
729
|
* WebSocket communication utilities.
|
|
@@ -647,12 +732,12 @@ declare global {
|
|
|
647
732
|
*
|
|
648
733
|
* @example
|
|
649
734
|
* ```js
|
|
650
|
-
* export default
|
|
735
|
+
* export default function chat(req) {
|
|
651
736
|
* if (req.event === "open") {
|
|
652
737
|
* t.ws.send(req.socketId, "Welcome!");
|
|
653
738
|
* t.ws.broadcast("Someone joined.");
|
|
654
739
|
* }
|
|
655
|
-
* }
|
|
740
|
+
* }
|
|
656
741
|
* ```
|
|
657
742
|
*/
|
|
658
743
|
ws: {
|
|
@@ -1012,6 +1097,19 @@ declare global {
|
|
|
1012
1097
|
*/
|
|
1013
1098
|
session: TitanCore.Session;
|
|
1014
1099
|
|
|
1100
|
+
/**
|
|
1101
|
+
* Titan Shared Context — Cross-isolate Shared In-Memory State.
|
|
1102
|
+
*
|
|
1103
|
+
* Provides a mechanism for sharing data across different isolates (requests)
|
|
1104
|
+
* and broadcasting events within the same server process.
|
|
1105
|
+
*
|
|
1106
|
+
* Data in `shareContext` is volatile and lost when the server exits.
|
|
1107
|
+
*
|
|
1108
|
+
* @see {@link TitanCore.ShareContext} for method signatures.
|
|
1109
|
+
* @see https://titanpl.vercel.app/docs/knowledge/05-titan-core — TitanCore Runtime APIs (t.shareContext)
|
|
1110
|
+
*/
|
|
1111
|
+
shareContext: TitanCore.ShareContext;
|
|
1112
|
+
|
|
1015
1113
|
/**
|
|
1016
1114
|
* HTTP cookie utilities for reading, setting, and deleting cookies.
|
|
1017
1115
|
*
|
|
@@ -1731,6 +1829,73 @@ declare global {
|
|
|
1731
1829
|
clear(sessionId: string): void;
|
|
1732
1830
|
}
|
|
1733
1831
|
|
|
1832
|
+
/**
|
|
1833
|
+
* Titan Shared Context — Cross-isolate Shared In-Memory State.
|
|
1834
|
+
*
|
|
1835
|
+
* Provides a mechanism for sharing data across different isolates (requests)
|
|
1836
|
+
* and broadcasting events within the same server process.
|
|
1837
|
+
*
|
|
1838
|
+
* Data in `shareContext` is in-memory only and is lost when the server process exits.
|
|
1839
|
+
*
|
|
1840
|
+
* @example
|
|
1841
|
+
* ```js
|
|
1842
|
+
* export function getStats(req) {
|
|
1843
|
+
* // Store a value common to all requests
|
|
1844
|
+
* t.shareContext.set("last_login", t.time.now());
|
|
1845
|
+
*
|
|
1846
|
+
* // Retrieve a value
|
|
1847
|
+
* const users = t.shareContext.get("active_users");
|
|
1848
|
+
*
|
|
1849
|
+
* // Broadcast a message to other workers
|
|
1850
|
+
* t.shareContext.broadcast("user_login", { user: "Titan" });
|
|
1851
|
+
* }
|
|
1852
|
+
* ```
|
|
1853
|
+
*
|
|
1854
|
+
* @see https://titanpl.vercel.app/docs/knowledge/05-titan-core — TitanCore Runtime APIs (t.shareContext)
|
|
1855
|
+
*/
|
|
1856
|
+
interface ShareContext {
|
|
1857
|
+
/**
|
|
1858
|
+
* Retrieve a value from the shared context.
|
|
1859
|
+
*
|
|
1860
|
+
* @param key - The key of the value to retrieve.
|
|
1861
|
+
* @returns The parsed value, or `null` if the key does not exist.
|
|
1862
|
+
*/
|
|
1863
|
+
get(key: string): any;
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* Store a value in the shared context.
|
|
1867
|
+
*
|
|
1868
|
+
* Values are serialized as JSON and must be serializable.
|
|
1869
|
+
*
|
|
1870
|
+
* @param key - The key to store under.
|
|
1871
|
+
* @param value - The JSON-serializable value to store.
|
|
1872
|
+
*/
|
|
1873
|
+
set(key: string, value: any): void;
|
|
1874
|
+
|
|
1875
|
+
/**
|
|
1876
|
+
* Remove a key and its value from the shared context.
|
|
1877
|
+
*
|
|
1878
|
+
* @param key - The key to remove.
|
|
1879
|
+
*/
|
|
1880
|
+
delete(key: string): void;
|
|
1881
|
+
|
|
1882
|
+
/**
|
|
1883
|
+
* Get a list of all keys currently in the shared context.
|
|
1884
|
+
*
|
|
1885
|
+
* @returns An array of string keys.
|
|
1886
|
+
*/
|
|
1887
|
+
keys(): string[];
|
|
1888
|
+
|
|
1889
|
+
/**
|
|
1890
|
+
* Broadcast an event and payload to other active isolates (requests)
|
|
1891
|
+
* and workers in this server process.
|
|
1892
|
+
*
|
|
1893
|
+
* @param event - The name of the event to broadcast.
|
|
1894
|
+
* @param payload - The payload of the event.
|
|
1895
|
+
*/
|
|
1896
|
+
broadcast(event: string, payload: any): void;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1734
1899
|
/**
|
|
1735
1900
|
* HTTP cookie management utilities.
|
|
1736
1901
|
*
|
package/packages/packet/index.js
CHANGED
|
@@ -67,6 +67,15 @@ export async function build(root = process.cwd()) {
|
|
|
67
67
|
outDir: dist,
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
const tanfigPath = path.join(root, "tanfig.json");
|
|
71
|
+
if (fs.existsSync(tanfigPath)) {
|
|
72
|
+
fs.copyFileSync(tanfigPath, path.join(dist, "tanfig.json"));
|
|
73
|
+
}
|
|
74
|
+
const titanExtPath = path.join(root, "titan.json");
|
|
75
|
+
if (fs.existsSync(titanExtPath)) {
|
|
76
|
+
fs.copyFileSync(titanExtPath, path.join(dist, "titan.json"));
|
|
77
|
+
}
|
|
78
|
+
|
|
70
79
|
return dist;
|
|
71
80
|
}
|
|
72
81
|
|
|
@@ -74,10 +83,19 @@ export async function build(root = process.cwd()) {
|
|
|
74
83
|
* Release build (Production ready folder)
|
|
75
84
|
*/
|
|
76
85
|
export async function release(root = process.cwd()) {
|
|
77
|
-
const dist = await build(root);
|
|
78
86
|
const buildDir = path.join(root, "build");
|
|
79
87
|
|
|
80
|
-
//
|
|
88
|
+
// Step 1: Pre-build (Production mode)
|
|
89
|
+
// Run production build to generate 'dist' folder
|
|
90
|
+
const dist = await build(root);
|
|
91
|
+
|
|
92
|
+
// Step 2: Clear or ensure build dir
|
|
93
|
+
if (fs.existsSync(buildDir)) {
|
|
94
|
+
fs.rmSync(buildDir, { recursive: true, force: true });
|
|
95
|
+
}
|
|
96
|
+
fs.mkdirSync(buildDir, { recursive: true });
|
|
97
|
+
|
|
98
|
+
// Step 3: Read config and files list
|
|
81
99
|
let config = {};
|
|
82
100
|
const configPath = fs.existsSync(path.join(root, "tanfig.json"))
|
|
83
101
|
? path.join(root, "tanfig.json")
|
|
@@ -91,41 +109,63 @@ export async function release(root = process.cwd()) {
|
|
|
91
109
|
} catch (e) { }
|
|
92
110
|
}
|
|
93
111
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
fs.rmSync(buildDir, { recursive: true, force: true });
|
|
99
|
-
}
|
|
100
|
-
fs.mkdirSync(buildDir, { recursive: true });
|
|
101
|
-
|
|
102
|
-
// 1. Copy dist
|
|
103
|
-
copyDir(dist, path.join(buildDir, "dist"));
|
|
112
|
+
// Default files to copy from root
|
|
113
|
+
const defaultFiles = ["public", "static", "db", "config", "views", "auth"];
|
|
114
|
+
const userFiles = config.build && Array.isArray(config.build.files) ? config.build.files : [];
|
|
115
|
+
const filesToCopy = Array.from(new Set([...defaultFiles, ...userFiles]));
|
|
104
116
|
|
|
105
|
-
//
|
|
117
|
+
// Step 4: Copy Files & Folders from root and app folders to build
|
|
106
118
|
for (const item of filesToCopy) {
|
|
119
|
+
// Check root first, then app/ folder
|
|
107
120
|
const src = path.join(root, item);
|
|
121
|
+
const appSrc = path.join(root, "app", item);
|
|
122
|
+
const dest = path.join(buildDir, item);
|
|
123
|
+
|
|
108
124
|
if (fs.existsSync(src)) {
|
|
109
|
-
const dest = path.join(buildDir, item);
|
|
110
125
|
copyDir(src, dest);
|
|
126
|
+
} else if (fs.existsSync(appSrc)) {
|
|
127
|
+
const appDest = path.join(buildDir, "app", item);
|
|
128
|
+
copyDir(appSrc, appDest);
|
|
111
129
|
}
|
|
112
130
|
}
|
|
113
131
|
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
132
|
+
// Step 5: Copy generated 'dist' (static routes/actions metadata)
|
|
133
|
+
copyDir(dist, path.join(buildDir, "dist"));
|
|
134
|
+
|
|
135
|
+
// Step 6: Copy essential config files (mandatory for runtime)
|
|
136
|
+
const essentials = ["package.json", "tanfig.json", "titan.json"];
|
|
137
|
+
for (const f of essentials) {
|
|
138
|
+
const src = path.join(root, f);
|
|
139
|
+
if (fs.existsSync(src)) {
|
|
140
|
+
fs.copyFileSync(src, path.join(buildDir, f));
|
|
141
|
+
}
|
|
118
142
|
}
|
|
119
143
|
|
|
120
|
-
//
|
|
144
|
+
// Step 7: Create .env for production
|
|
121
145
|
fs.writeFileSync(path.join(buildDir, ".env"), "TITAN_DEV=0\n");
|
|
122
146
|
|
|
123
|
-
//
|
|
147
|
+
// Step 8: Extract Extensions
|
|
124
148
|
const extDir = path.join(buildDir, ".ext");
|
|
125
149
|
fs.mkdirSync(extDir, { recursive: true });
|
|
126
150
|
|
|
127
151
|
const nodeModules = path.join(root, "node_modules");
|
|
128
152
|
if (fs.existsSync(nodeModules)) {
|
|
153
|
+
const localPkgs = path.resolve(root, "../../packages");
|
|
154
|
+
if (fs.existsSync(localPkgs)) {
|
|
155
|
+
const pkgs = fs.readdirSync(localPkgs);
|
|
156
|
+
for (const pkg of pkgs) {
|
|
157
|
+
const pkgPath = path.join(localPkgs, pkg);
|
|
158
|
+
const titanJsonPath = path.join(pkgPath, "titan.json");
|
|
159
|
+
if (fs.existsSync(titanJsonPath)) {
|
|
160
|
+
try {
|
|
161
|
+
const config = JSON.parse(fs.readFileSync(titanJsonPath, "utf8"));
|
|
162
|
+
const extName = config.name;
|
|
163
|
+
const dest = path.join(extDir, extName.includes("/") ? extName : extName);
|
|
164
|
+
copyDir(pkgPath, dest);
|
|
165
|
+
} catch(e) {}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
129
169
|
const findExtensions = (dir, depth = 0) => {
|
|
130
170
|
if (depth > 2) return;
|
|
131
171
|
if (!fs.existsSync(dir)) return;
|
|
@@ -147,6 +187,8 @@ export async function release(root = process.cwd()) {
|
|
|
147
187
|
}
|
|
148
188
|
|
|
149
189
|
const destPath = path.join(extDir, targetPkgName);
|
|
190
|
+
if (fs.existsSync(destPath)) continue; // Don't overwrite monorepo packages
|
|
191
|
+
|
|
150
192
|
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
151
193
|
|
|
152
194
|
copyDir(fullPath, destPath, (src) => {
|
|
@@ -161,98 +203,65 @@ export async function release(root = process.cwd()) {
|
|
|
161
203
|
}
|
|
162
204
|
};
|
|
163
205
|
findExtensions(nodeModules);
|
|
164
|
-
}
|
|
165
206
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// 7. Create node_modules junction to .ext for engine resolution
|
|
179
|
-
// If env is 'deploy' or 'production', we might want to skip this for a cleaner build
|
|
180
|
-
const buildEnv = config.build && (config.build.env || config.build.purpose) ? (config.build.env || config.build.purpose) : "test";
|
|
181
|
-
|
|
182
|
-
if (buildEnv !== "deploy" && buildEnv !== "production") {
|
|
183
|
-
const nmSymlink = path.join(buildDir, "node_modules");
|
|
184
|
-
if (!fs.existsSync(nmSymlink)) {
|
|
185
|
-
try {
|
|
186
|
-
// Junctions don't require admin on Windows
|
|
187
|
-
fs.symlinkSync(".ext", nmSymlink, "junction");
|
|
188
|
-
} catch (e) {
|
|
189
|
-
try {
|
|
190
|
-
fs.symlinkSync(".ext", nmSymlink, "dir");
|
|
191
|
-
} catch (e2) {
|
|
192
|
-
// Fallback or ignore if symlink creation is totally restricted
|
|
207
|
+
// Also copy engine binaries if they exist in node_modules
|
|
208
|
+
if (fs.existsSync(path.join(nodeModules, "@titanpl"))) {
|
|
209
|
+
const scopeDir = path.join(nodeModules, "@titanpl");
|
|
210
|
+
const folders = fs.readdirSync(scopeDir);
|
|
211
|
+
for (const folder of folders) {
|
|
212
|
+
if (folder.startsWith("engine-") || folder.startsWith("runtime-")) {
|
|
213
|
+
const engineDest = path.join(extDir, "@titanpl", folder);
|
|
214
|
+
copyDir(path.join(scopeDir, folder), engineDest);
|
|
193
215
|
}
|
|
194
216
|
}
|
|
195
217
|
}
|
|
196
218
|
}
|
|
197
219
|
|
|
198
|
-
//
|
|
220
|
+
// Step 9: Copy/Extract titan-server binary to build root
|
|
199
221
|
const binName = process.platform === "win32" ? "titan-server.exe" : "titan-server";
|
|
200
222
|
let engineBin = null;
|
|
201
223
|
|
|
202
|
-
//
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
return null;
|
|
224
|
+
// Search in .ext
|
|
225
|
+
const searchBin = (dir) => {
|
|
226
|
+
if (!fs.existsSync(dir)) return null;
|
|
227
|
+
const entries = fs.readdirSync(dir);
|
|
228
|
+
for (const e of entries) {
|
|
229
|
+
const full = path.join(dir, e);
|
|
230
|
+
if (fs.statSync(full).isDirectory()) {
|
|
231
|
+
const p1 = path.join(full, "bin", binName);
|
|
232
|
+
if (fs.existsSync(p1)) return p1;
|
|
233
|
+
const p2 = path.join(full, binName);
|
|
234
|
+
if (fs.existsSync(p2)) return p2;
|
|
235
|
+
const found = searchBin(full);
|
|
236
|
+
if (found) return found;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
220
240
|
};
|
|
241
|
+
engineBin = searchBin(extDir);
|
|
221
242
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// Strategy B: Monorepo fallback (if building inside the titanpl repo)
|
|
243
|
+
// Fallback to monorepo binary (if building in repo)
|
|
225
244
|
if (!engineBin) {
|
|
226
|
-
let
|
|
227
|
-
for
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (parent === current) break;
|
|
235
|
-
current = parent;
|
|
245
|
+
let curr = root;
|
|
246
|
+
for(let i=0; i<3; i++) {
|
|
247
|
+
const potential = path.join(curr, "engine", "target", "release", binName);
|
|
248
|
+
if (fs.existsSync(potential)) {
|
|
249
|
+
engineBin = potential;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
curr = path.dirname(curr);
|
|
236
253
|
}
|
|
237
254
|
}
|
|
238
255
|
|
|
239
256
|
if (engineBin) {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (!fs.existsSync(linkPath)) {
|
|
244
|
-
try {
|
|
245
|
-
// Always copy the binary to the root for maximum portability in the 'build' folder
|
|
246
|
-
fs.copyFileSync(engineBin, linkPath);
|
|
247
|
-
if (process.platform !== "win32") {
|
|
248
|
-
fs.chmodSync(linkPath, 0o755);
|
|
249
|
-
}
|
|
250
|
-
} catch (e) {
|
|
251
|
-
console.error(`[Titan] Failed to create titan binary: ${e.message}`);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
257
|
+
const destBin = path.join(buildDir, binName);
|
|
258
|
+
fs.copyFileSync(engineBin, destBin);
|
|
259
|
+
if (process.platform !== "win32") fs.chmodSync(destBin, 0o755);
|
|
254
260
|
}
|
|
255
261
|
|
|
262
|
+
// Step 10: In production builds, we DON'T use symlinks for node_modules.
|
|
263
|
+
// Instead, the engine knows to look in .ext.
|
|
264
|
+
|
|
256
265
|
return buildDir;
|
|
257
266
|
}
|
|
258
267
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@titanpl/sdk",
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"description": "The official SDK for Titan Planet extensions and testing.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./test": "./test/index.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"titanpl",
|
|
13
|
+
"titan",
|
|
14
|
+
"sdk"
|
|
15
|
+
],
|
|
16
|
+
"author": "ezetgalaxy",
|
|
17
|
+
"license": "ISC"
|
|
18
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import vm from 'node:vm';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a lightweight production-grade test environment for Titan extensions.
|
|
8
|
+
* Provides isolation via node:vm and a full t-object emulation.
|
|
9
|
+
*/
|
|
10
|
+
export async function createTestEnv(options) {
|
|
11
|
+
const { extPath, allowWasm = false, allowNative = false } = options;
|
|
12
|
+
const absolutePath = path.resolve(extPath);
|
|
13
|
+
const titanJsonPath = path.join(absolutePath, 'titan.json');
|
|
14
|
+
|
|
15
|
+
if (!fs.existsSync(titanJsonPath)) {
|
|
16
|
+
throw new Error(`[@titanpl/sdk/test] titan.json not found at ${absolutePath}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const titanJson = JSON.parse(fs.readFileSync(titanJsonPath, 'utf8'));
|
|
20
|
+
|
|
21
|
+
// Create the global 't' mock
|
|
22
|
+
const tMock = {
|
|
23
|
+
_logs: [],
|
|
24
|
+
_calls: [],
|
|
25
|
+
log: (name, ...args) => {
|
|
26
|
+
const entry = `[${name}] ${args.join(' ')}`;
|
|
27
|
+
tMock._logs.push(entry);
|
|
28
|
+
console.log('\x1b[36m%s\x1b[0m', entry);
|
|
29
|
+
},
|
|
30
|
+
__native: {
|
|
31
|
+
call: async (ext, fn, args) => {
|
|
32
|
+
if (!allowNative) throw new Error(`[@titanpl/sdk/test] Native call blocked (allowNative: false)`);
|
|
33
|
+
tMock._calls.push({ type: 'native', ext, fn, args });
|
|
34
|
+
return `[MOCK_NATIVE_RESULT]`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Create a VM context
|
|
40
|
+
const context = {
|
|
41
|
+
t: tMock,
|
|
42
|
+
global: {},
|
|
43
|
+
globalThis: {},
|
|
44
|
+
console: console,
|
|
45
|
+
setTimeout,
|
|
46
|
+
clearTimeout,
|
|
47
|
+
process: { env: { ...process.env } }
|
|
48
|
+
};
|
|
49
|
+
context.global = context;
|
|
50
|
+
context.globalThis = context;
|
|
51
|
+
|
|
52
|
+
vm.createContext(context);
|
|
53
|
+
|
|
54
|
+
// Load extension entry
|
|
55
|
+
const entryPath = path.join(absolutePath, titanJson.entry);
|
|
56
|
+
const code = fs.readFileSync(entryPath, 'utf8');
|
|
57
|
+
|
|
58
|
+
// Resolve relative imports within the extension
|
|
59
|
+
// Simple loader: replace relative imports with absolute ones or mock them
|
|
60
|
+
// For a real production-ready test env, we'd use a custom loader or compile with ESBuild.
|
|
61
|
+
// For now, we'll use a functional script wrapper.
|
|
62
|
+
|
|
63
|
+
const script = new vm.Script(`
|
|
64
|
+
(async () => {
|
|
65
|
+
${code.replace(/import\s+{([^}]+)}\s+from\s+'\.\/utils\/registerExtension\.js'/g, 'const {$1} = t._registerHelper;')}
|
|
66
|
+
})()
|
|
67
|
+
`);
|
|
68
|
+
|
|
69
|
+
// Add registration helper to 't'
|
|
70
|
+
tMock._registerHelper = {
|
|
71
|
+
registerExtension: (name, module) => {
|
|
72
|
+
tMock[name] = module;
|
|
73
|
+
console.log(`[@titanpl/sdk/test] Registered extension: ${name}`);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await script.runInContext(context);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error(`[@titanpl/sdk/test] Runtime error in extension '${titanJson.name}':`, err);
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
/**
|
|
86
|
+
* Call an extension method
|
|
87
|
+
*/
|
|
88
|
+
call: async (path, args = []) => {
|
|
89
|
+
const [extName, methodName] = path.split('.');
|
|
90
|
+
if (!tMock[extName]) throw new Error(`Extension '${extName}' not registered`);
|
|
91
|
+
if (!tMock[extName][methodName]) throw new Error(`Method '${methodName}' not found on extension '${extName}'`);
|
|
92
|
+
|
|
93
|
+
return await tMock[extName][methodName](...args);
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Assert a method result
|
|
98
|
+
*/
|
|
99
|
+
assert: async (path, args, expected) => {
|
|
100
|
+
const result = await tMock.call(path, args);
|
|
101
|
+
if (JSON.stringify(result) !== JSON.stringify(expected)) {
|
|
102
|
+
throw new Error(`Assertion Failed for ${path}\nExpected: ${JSON.stringify(expected)}\nActual: ${JSON.stringify(result)}`);
|
|
103
|
+
}
|
|
104
|
+
console.log(`\x1b[32m✔ Assertion Passed: ${path}\x1b[0m`);
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get all logs captured during execution
|
|
109
|
+
*/
|
|
110
|
+
getLogs: () => tMock._logs,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Teardown the environment
|
|
114
|
+
*/
|
|
115
|
+
teardown: async () => {
|
|
116
|
+
// Cleanup context and references
|
|
117
|
+
for (const key in tMock) delete tMock[key];
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"description": "A powerful TitanPL project",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"extensions": {
|
|
6
|
+
"allowWasm": true,
|
|
7
|
+
"allowNative": [
|
|
8
|
+
"@titanpl/core"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"build": {
|
|
12
|
+
"purpose": "test",
|
|
13
|
+
"files": [
|
|
14
|
+
"public",
|
|
15
|
+
"static",
|
|
16
|
+
"db",
|
|
17
|
+
"tanfig.json"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
14
20
|
}
|