Skip to content

[5.4.0] Formalize data tiddlers#9336

Open
Arlen22 wants to merge 7 commits intoTiddlyWiki:masterfrom
Arlen22:data-tiddler-modules
Open

[5.4.0] Formalize data tiddlers#9336
Arlen22 wants to merge 7 commits intoTiddlyWiki:masterfrom
Arlen22:data-tiddler-modules

Conversation

@Arlen22
Copy link
Member

@Arlen22 Arlen22 commented Oct 11, 2025

This PR

  • adds a preloadHooks array
  • adds a data tiddler serializer module
  • uses tiddler.isPlugin for all plugin checks
  • converts plugin parsing and serializing to use the data tiddler serializer since plugins are already considered data tiddlers.
  • Does not change the default plugin type or add new plugin container formats.

This is related to #9068 and #9064.

Breaking Changes: 5.4.0

The major breaking change in this PR is that plugins must now be parsed like this.

const plugin = $tw.wiki.getTiddler(title); // the plugin tiddler
if(!tiddler.isPlugin()) throw new Error("not a plugin");
const { tiddlers } = $tw.utils.parseDataTiddler(plugin.fields.type, plugin.fields.text);

and stringified like this

const newfields = { type: "application/json" };
newFields.text = $tw.utils.stringifyDataTiddler(newfields.type, { tiddlers });

This adds the following methods to $tw.utils

parseDataTiddler(type: string, text: string): any;
stringifyDataTiddler(type: string, data: any): string;
isValidDataTiddlerType(type: string): boolean;

It adds the module-type datatiddlerserializer with the following interface.

interface DataTiddlerSerializer {
  name: string;
  parse: (text: string) => any;
  stringify: (data: any) => string;
}

Registered serializers are a hashmap on the $tw.Wiki.dataTiddlerSerializerModules static property.

It registers two data tiddler types

  • application/json - the usual format that plugins use
  • x-tiddler-dictionary - the format used for things like color palettes.

Under the hood both of these are data tiddler formats.


Data tiddler types are rarely interchangeable unless they have an explicitly defined relationship.

A plugin qualifies as a data tiddler, which inspired me to just make it official instead of accounting for all the cases of x-tiddler-dictionary. Of course, x-tiddler-dictionary has additional constraints. It cannot be used for a plugin, as it requires the data to be of type Record<string, string> (aka a hashmap of strings). But setting the type field is very explicit.

@netlify
Copy link

netlify bot commented Oct 11, 2025

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit ab2b60e
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/695e9163b202ea0008f2f551
😎 Deploy Preview https://deploy-preview-9336--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

Confirmed: Arlen22 has already signed the Contributor License Agreement (see contributing.md)

@github-actions
Copy link

github-actions bot commented Oct 11, 2025

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2421.1 KB
PR 2562.5 KB

Diff: ⬆️ Increase: +141.3 KB

🔴 Significant Increase

⚠️ Warning: Size increased significantly.

@Arlen22 Arlen22 force-pushed the data-tiddler-modules branch 3 times, most recently from 7a8f1c4 to ff5307c Compare October 11, 2025 16:36
- trying to find as many uses of plugins as I can
@Arlen22 Arlen22 force-pushed the data-tiddler-modules branch from ff5307c to fdaf9f6 Compare October 11, 2025 22:51
@Arlen22 Arlen22 changed the title Add preloadHooks and data tiddler serializer [5.4.0] Formalize data tiddlers Oct 11, 2025
@pmario pmario added the needswork PR that cannot yet be merged; Issue that is "almost" actionable label Dec 15, 2025
@Arlen22
Copy link
Member Author

Arlen22 commented Dec 17, 2025

Add separate change notes for preloadHooks and datatiddlerserializer

@Arlen22 Arlen22 mentioned this pull request Jan 7, 2026
@Arlen22
Copy link
Member Author

Arlen22 commented Jan 7, 2026

@Jermolene is this ready to merge? I think I'm ready.

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2449.5 KB
PR 2591.5 KB

Diff: ⬆️ Increase: +142.0 KB

🔴 Significant Increase

⚠️ Warning: Size increased significantly.


✅ Change Note Status

All change notes are properly formatted and validated!

📝 $:/changenotes/5.4.0/#9336

Type: enhancement | Category: developer
Release: 5.4.0

Formalize data tiddlers and add preloadHooks array

🔗 #9336

👥 Contributors: Arlen22


📖 Change Note Guidelines

Change notes help track and communicate changes effectively. See the full documentation for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needswork PR that cannot yet be merged; Issue that is "almost" actionable

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants