Loading CHANGES.md +3 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,9 @@ To be released. - `Object.clone()` method now accepts `proof` option. - `Object.clone()` method now accepts `proofs` option. - Added `context` option to `Object.toJsonLd()` method. This applies to any subclasses of the `Object` class too. - Deprecated `treatHttps` option in `FederationParameters` interface. Instead, use the [x-forwarded-fetch] library to recognize the `X-Forwarded-Host` and `X-Forwarded-Proto` headers. Loading codegen/__snapshots__/class.test.ts.snap +96 −48 File changed.Preview size limit exceeded, changes collapsed. Show changes codegen/codec.ts +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ export async function* generateEncoder( async toJsonLd(options: { expand?: boolean, contextLoader?: DocumentLoader, context?: string | Record<string, string> | (string | Record<string, string>)[], } = {}): Promise<unknown> { options = { ...options, Loading Loading @@ -69,7 +70,7 @@ export async function* generateEncoder( } return await jsonld.compact( values, ${JSON.stringify(type.defaultContext)}, options.context ?? ${JSON.stringify(type.defaultContext)}, { documentLoader: options.contextLoader }, ); } Loading vocab/vocab.test.ts +17 −5 Original line number Diff line number Diff line Loading @@ -724,15 +724,27 @@ for (const typeUri in types) { }); assertEquals(restored, instance); const jsonLd2 = await instance.toJsonLd({ contextLoader: mockDocumentLoader, context: "https://www.w3.org/ns/activitystreams", }); assertEquals(jsonLd2["@context"], "https://www.w3.org/ns/activitystreams"); assertEquals(jsonLd2.id, "https://example.com/"); const restored2 = await cls.fromJsonLd(jsonLd2, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }); assertEquals(restored2, instance); const expanded = await instance.toJsonLd({ contextLoader: mockDocumentLoader, expand: true, }); const restored2 = await cls.fromJsonLd(expanded, { const restored3 = await cls.fromJsonLd(expanded, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }); assertEquals(restored2, instance); assertEquals(restored3, instance); const instance2 = new cls({ id: new URL("https://example.com/"), Loading @@ -746,14 +758,14 @@ for (const typeUri in types) { ), ), }); const jsonLd2 = await instance2.toJsonLd({ const jsonLd3 = await instance2.toJsonLd({ contextLoader: mockDocumentLoader, }); const restored3 = await cls.fromJsonLd(jsonLd2, { const restored4 = await cls.fromJsonLd(jsonLd3, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }); assertEquals(restored3, instance2); assertEquals(restored4, instance2); }); if (isDeno) { Loading Loading
CHANGES.md +3 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,9 @@ To be released. - `Object.clone()` method now accepts `proof` option. - `Object.clone()` method now accepts `proofs` option. - Added `context` option to `Object.toJsonLd()` method. This applies to any subclasses of the `Object` class too. - Deprecated `treatHttps` option in `FederationParameters` interface. Instead, use the [x-forwarded-fetch] library to recognize the `X-Forwarded-Host` and `X-Forwarded-Proto` headers. Loading
codegen/__snapshots__/class.test.ts.snap +96 −48 File changed.Preview size limit exceeded, changes collapsed. Show changes
codegen/codec.ts +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ export async function* generateEncoder( async toJsonLd(options: { expand?: boolean, contextLoader?: DocumentLoader, context?: string | Record<string, string> | (string | Record<string, string>)[], } = {}): Promise<unknown> { options = { ...options, Loading Loading @@ -69,7 +70,7 @@ export async function* generateEncoder( } return await jsonld.compact( values, ${JSON.stringify(type.defaultContext)}, options.context ?? ${JSON.stringify(type.defaultContext)}, { documentLoader: options.contextLoader }, ); } Loading
vocab/vocab.test.ts +17 −5 Original line number Diff line number Diff line Loading @@ -724,15 +724,27 @@ for (const typeUri in types) { }); assertEquals(restored, instance); const jsonLd2 = await instance.toJsonLd({ contextLoader: mockDocumentLoader, context: "https://www.w3.org/ns/activitystreams", }); assertEquals(jsonLd2["@context"], "https://www.w3.org/ns/activitystreams"); assertEquals(jsonLd2.id, "https://example.com/"); const restored2 = await cls.fromJsonLd(jsonLd2, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }); assertEquals(restored2, instance); const expanded = await instance.toJsonLd({ contextLoader: mockDocumentLoader, expand: true, }); const restored2 = await cls.fromJsonLd(expanded, { const restored3 = await cls.fromJsonLd(expanded, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }); assertEquals(restored2, instance); assertEquals(restored3, instance); const instance2 = new cls({ id: new URL("https://example.com/"), Loading @@ -746,14 +758,14 @@ for (const typeUri in types) { ), ), }); const jsonLd2 = await instance2.toJsonLd({ const jsonLd3 = await instance2.toJsonLd({ contextLoader: mockDocumentLoader, }); const restored3 = await cls.fromJsonLd(jsonLd2, { const restored4 = await cls.fromJsonLd(jsonLd3, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader, }); assertEquals(restored3, instance2); assertEquals(restored4, instance2); }); if (isDeno) { Loading