Skip to content

Commit

Permalink
changes for Meteor v3
Browse files Browse the repository at this point in the history
  • Loading branch information
copleykj committed Sep 28, 2024
1 parent 97dd710 commit 8d19471
Show file tree
Hide file tree
Showing 15 changed files with 907 additions and 191 deletions.
11 changes: 10 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,14 @@
"node_modules",
"tests"
],
"settings": {}
"settings": {
"import/resolver": {
"meteor": {
"extensions": [
".js",
".jsx"
]
}
}
}
}
5 changes: 1 addition & 4 deletions lib/client.js → lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { InjectData } from './namespace';
// Automatically parse the inject-data payload on Meteor startup
// Load it into memory so it can be fetched by InjectData.getData
Meteor.startup(function () {
const dom = document.querySelectorAll(
'script[type="text/inject-data"]',
document,
);
const dom = document.querySelectorAll('script[type="text/inject-data"]');
const injectedDataString = dom && dom.length > 0 ? dom[0].innerHTML : '';
InjectData._data = InjectData._decode(injectedDataString) || {};
});
Expand Down
8 changes: 6 additions & 2 deletions lib/namespace.js → lib/namespace.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/* global Package */
export const InjectData = {};
export let InjectData: {
getData: (key: string, callback: (data: any) => any) => void;
};

InjectData = {};
// Replace meteorhacks:inject-data with our new API, this is for compatibility
// with third party packages that still depend upon the meteorhacks version.
if (Package['meteorhacks:inject-data']) {
Package['meteorhacks:inject-data'].InjectData = InjectData;
}

Meteor.User;
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WebAppInternals } from 'meteor/webapp';
InjectData.injectToHead = true;
Meteor.startup(() => {
WebAppInternals.registerBoilerplateDataCallback(
'communitypackages:fast-render',
'communitypackages:inject-data',
(req, data) => {
if (
req &&
Expand Down
Loading

0 comments on commit 8d19471

Please sign in to comment.